Skip to content

Commit 6503868

Browse files
committed
merge with main
1 parent 96acbd4 commit 6503868

2 files changed

Lines changed: 175 additions & 175 deletions

File tree

Lines changed: 125 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -1,125 +1,125 @@
1-
#pragma once
2-
#include <exception>
3-
#include <string>
4-
5-
using namespace std;
6-
7-
class GameException : public exception{
8-
protected :
9-
string message;
10-
public :
11-
GameException(const string& message);
12-
virtual const char* what() const noexcept;
13-
};
14-
15-
16-
// ECONOMY
17-
class InsufficientFundsException : public GameException {
18-
private :
19-
int required;
20-
int cur;
21-
public :
22-
InsufficientFundsException(const int& required, const int& cur);
23-
};
24-
25-
// CARD
26-
class InventoryFullException : public GameException{
27-
public :
28-
InventoryFullException();
29-
};
30-
31-
class CardNotFoundException : public GameException{
32-
private :
33-
string cardName;
34-
public :
35-
CardNotFoundException(const string& cardName);
36-
};
37-
38-
class AlreadyUseCardException : public GameException{
39-
public :
40-
AlreadyUseCardException();
41-
};
42-
43-
class UseCardAfterDiceException : public GameException{
44-
public :
45-
UseCardAfterDiceException();
46-
};
47-
48-
// Property
49-
class TileNotFoundException : public GameException{
50-
private :
51-
string code;
52-
public :
53-
TileNotFoundException(const string& code);
54-
};
55-
56-
class PropertyNotOwnedException : public GameException{
57-
public :
58-
PropertyNotOwnedException();
59-
};
60-
61-
class PropertyAlreadyOwnedException : public GameException{
62-
public :
63-
PropertyAlreadyOwnedException();
64-
};
65-
66-
// MORTGAGE
67-
class PropertyMortgagedException : public GameException{
68-
public :
69-
PropertyMortgagedException();
70-
};
71-
72-
class NotMortgagedException : public GameException{
73-
public :
74-
NotMortgagedException();
75-
};
76-
77-
class HasBuildingForMortgage : public GameException{
78-
public :
79-
HasBuildingForMortgage();
80-
};
81-
82-
// BUILD
83-
class UnevenBuildingException : public GameException{
84-
private :
85-
string color;
86-
public :
87-
UnevenBuildingException(const string& color);
88-
};
89-
90-
class MaxBuildingException : public GameException{
91-
public :
92-
MaxBuildingException();
93-
};
94-
95-
class UpgradeHotelException : public GameException{
96-
public :
97-
UpgradeHotelException();
98-
};
99-
100-
// INPUT
101-
class InvalidCommandException : public GameException{
102-
public :
103-
InvalidCommandException();
104-
};
105-
106-
class InvalidArgumentException : public GameException{
107-
private :
108-
string arg;
109-
public :
110-
InvalidArgumentException(const string& arg);
111-
};
112-
113-
// Dice
114-
class RollDiceException : public GameException{
115-
public :
116-
RollDiceException();
117-
};
118-
119-
// System
120-
class FileNotFoundException : public GameException{
121-
private :
122-
string filename;
123-
public :
124-
FileNotFoundException(const string& filename);
125-
};
1+
#pragma once
2+
#include <exception>
3+
#include <string>
4+
5+
using namespace std;
6+
7+
class GameException : public exception{
8+
protected :
9+
string message;
10+
public :
11+
GameException(const string& message);
12+
virtual const char* what() const noexcept;
13+
};
14+
15+
16+
// ECONOMY
17+
class InsufficientFundsException : public GameException {
18+
private :
19+
int required;
20+
int cur;
21+
public :
22+
InsufficientFundsException(const int& required, const int& cur);
23+
};
24+
25+
// CARD
26+
class InventoryFullException : public GameException{
27+
public :
28+
InventoryFullException();
29+
};
30+
31+
class CardNotFoundException : public GameException{
32+
private :
33+
string cardName;
34+
public :
35+
CardNotFoundException(const string& cardName);
36+
};
37+
38+
class AlreadyUseCardException : public GameException{
39+
public :
40+
AlreadyUseCardException();
41+
};
42+
43+
class UseCardAfterDiceException : public GameException{
44+
public :
45+
UseCardAfterDiceException();
46+
};
47+
48+
// Property
49+
class TileNotFoundException : public GameException{
50+
private :
51+
string code;
52+
public :
53+
TileNotFoundException(const string& code);
54+
};
55+
56+
class PropertyNotOwnedException : public GameException{
57+
public :
58+
PropertyNotOwnedException();
59+
};
60+
61+
class PropertyAlreadyOwnedException : public GameException{
62+
public :
63+
PropertyAlreadyOwnedException();
64+
};
65+
66+
// MORTGAGE
67+
class PropertyMortgagedException : public GameException{
68+
public :
69+
PropertyMortgagedException();
70+
};
71+
72+
class NotMortgagedException : public GameException{
73+
public :
74+
NotMortgagedException();
75+
};
76+
77+
class HasBuildingForMortgage : public GameException{
78+
public :
79+
HasBuildingForMortgage();
80+
};
81+
82+
// BUILD
83+
class UnevenBuildingException : public GameException{
84+
private :
85+
string color;
86+
public :
87+
UnevenBuildingException(const string& color);
88+
};
89+
90+
class MaxBuildingException : public GameException{
91+
public :
92+
MaxBuildingException();
93+
};
94+
95+
class UpgradeHotelException : public GameException{
96+
public :
97+
UpgradeHotelException();
98+
};
99+
100+
// INPUT
101+
class InvalidCommandException : public GameException{
102+
public :
103+
InvalidCommandException();
104+
};
105+
106+
class InvalidArgumentException : public GameException{
107+
private :
108+
string arg;
109+
public :
110+
InvalidArgumentException(const string& arg);
111+
};
112+
113+
// Dice
114+
class RollDiceException : public GameException{
115+
public :
116+
RollDiceException();
117+
};
118+
119+
// System
120+
class FileNotFoundException : public GameException{
121+
private :
122+
string filename;
123+
public :
124+
FileNotFoundException(const string& filename);
125+
};

src/exception/GameException.cpp

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,50 @@
1-
#include "GameException.hpp"
2-
3-
GameException::GameException(const string& message) : message(message){}
4-
5-
const char* GameException::what() const noexcept{
6-
return message.c_str();
7-
}
8-
9-
// ECONOMY
10-
InsufficientFundsException::InsufficientFundsException(const int& required, const int& cur)
11-
: GameException("Uang tidak mencukup! Butuh: M" + to_string(required) + ", Anda hanya memiliki M" + to_string(cur)),required(required),cur(cur) {}
12-
13-
// CARD
14-
InventoryFullException::InventoryFullException():GameException("Inventory kamu penuh! Anda sudah memiliki 3 kartu."){}
15-
16-
CardNotFoundException::CardNotFoundException(const string& cardName): GameException("Kamu tidak memiliki kartu: " + cardName + "!"),cardName(cardName){}
17-
18-
AlreadyUseCardException::AlreadyUseCardException():GameException("Kamu hanya boleh menggunakan satu kartu dalam satu giliran!"){}
19-
20-
UseCardAfterDiceException::UseCardAfterDiceException():GameException("Kamu tidak bisa menggunakan kartu setelah mengocok dadu!"){}
21-
22-
// Property
23-
TileNotFoundException::TileNotFoundException(const string& code): GameException("Petak dengan kode " + code + " tidak ditemukan!"), code(code){}
24-
25-
PropertyNotOwnedException::PropertyNotOwnedException(): GameException("Properti ini belum dimiliki oleh siapapun!"){}
26-
27-
PropertyAlreadyOwnedException::PropertyAlreadyOwnedException(): GameException("Properti ini sudah dimiliki oleh orang lain!"){}
28-
29-
PropertyMortgagedException::PropertyMortgagedException(): GameException("Properti ini sedang digadaikan!"){}
30-
31-
NotMortgagedException::NotMortgagedException(): GameException("Properti ini tidak sedang digadaikan!"){}
32-
33-
HasBuildingForMortgage::HasBuildingForMortgage(): GameException("Masih ada bangunan di color group ini. Bangunan harus dijual terlebih dahulu!"){}
34-
35-
UnevenBuildingException::UnevenBuildingException(const string& color): GameException("Pembangunan harus merata! Selisih jumlah rumah di color group " + color + " tidak boleh lebih dari satu!"){}
36-
37-
MaxBuildingException::MaxBuildingException():GameException("Petak ini sudah mencapai batas pembangunan!"){}
38-
39-
UpgradeHotelException::UpgradeHotelException():GameException("Seluruh petak dalam color group harus memiliki 4 rumah sebelum bisa upgrade ke Hotel!"){}
40-
41-
// INPUT
42-
InvalidCommandException::InvalidCommandException():GameException("Perintah tidak valid!"){}
43-
44-
InvalidArgumentException::InvalidArgumentException(const string& arg):GameException("Argumen: " + arg + " tidak valid!"), arg(arg){}
45-
46-
// DICE
47-
RollDiceException::RollDiceException(): GameException("Angka dadu harus berada di antara 1 sampai 6!"){}
48-
49-
// SYSTEM
50-
FileNotFoundException::FileNotFoundException(const string& filename): GameException("File: " + filename + " tidak ditemukan!"){}
1+
#include "GameException.hpp"
2+
3+
GameException::GameException(const string& message) : message(message){}
4+
5+
const char* GameException::what() const noexcept{
6+
return message.c_str();
7+
}
8+
9+
// ECONOMY
10+
InsufficientFundsException::InsufficientFundsException(const int& required, const int& cur)
11+
: GameException("Uang tidak mencukup! Butuh: M" + to_string(required) + ", Anda hanya memiliki M" + to_string(cur)),required(required),cur(cur) {}
12+
13+
// CARD
14+
InventoryFullException::InventoryFullException():GameException("Inventory kamu penuh! Anda sudah memiliki 3 kartu."){}
15+
16+
CardNotFoundException::CardNotFoundException(const string& cardName): GameException("Kamu tidak memiliki kartu: " + cardName + "!"),cardName(cardName){}
17+
18+
AlreadyUseCardException::AlreadyUseCardException():GameException("Kamu hanya boleh menggunakan satu kartu dalam satu giliran!"){}
19+
20+
UseCardAfterDiceException::UseCardAfterDiceException():GameException("Kamu tidak bisa menggunakan kartu setelah mengocok dadu!"){}
21+
22+
// Property
23+
TileNotFoundException::TileNotFoundException(const string& code): GameException("Petak dengan kode " + code + " tidak ditemukan!"), code(code){}
24+
25+
PropertyNotOwnedException::PropertyNotOwnedException(): GameException("Properti ini belum dimiliki oleh siapapun!"){}
26+
27+
PropertyAlreadyOwnedException::PropertyAlreadyOwnedException(): GameException("Properti ini sudah dimiliki oleh orang lain!"){}
28+
29+
PropertyMortgagedException::PropertyMortgagedException(): GameException("Properti ini sedang digadaikan!"){}
30+
31+
NotMortgagedException::NotMortgagedException(): GameException("Properti ini tidak sedang digadaikan!"){}
32+
33+
HasBuildingForMortgage::HasBuildingForMortgage(): GameException("Masih ada bangunan di color group ini. Bangunan harus dijual terlebih dahulu!"){}
34+
35+
UnevenBuildingException::UnevenBuildingException(const string& color): GameException("Pembangunan harus merata! Selisih jumlah rumah di color group " + color + " tidak boleh lebih dari satu!"){}
36+
37+
MaxBuildingException::MaxBuildingException():GameException("Petak ini sudah mencapai batas pembangunan!"){}
38+
39+
UpgradeHotelException::UpgradeHotelException():GameException("Seluruh petak dalam color group harus memiliki 4 rumah sebelum bisa upgrade ke Hotel!"){}
40+
41+
// INPUT
42+
InvalidCommandException::InvalidCommandException():GameException("Perintah tidak valid!"){}
43+
44+
InvalidArgumentException::InvalidArgumentException(const string& arg):GameException("Argumen: " + arg + " tidak valid!"), arg(arg){}
45+
46+
// DICE
47+
RollDiceException::RollDiceException(): GameException("Angka dadu harus berada di antara 1 sampai 6!"){}
48+
49+
// SYSTEM
50+
FileNotFoundException::FileNotFoundException(const string& filename): GameException("File: " + filename + " tidak ditemukan!"){}

0 commit comments

Comments
 (0)