fix segmentation fault and revise file name
master
Sterben-01 2022-10-16 05:09:39 -05:00
parent 72d36140b3
commit 640e6ffde2
3 changed files with 9 additions and 11 deletions

View File

@ -19,7 +19,12 @@ GameAccount::GameAccount(string iName){
name = iName;
setLevel(new Primary(this));
}
GameAccount::~GameAccount(){
if(level){
delete level;
level = nullptr;
}
}
void GameAccount::setLevel(Level* iLevel){
if(level != nullptr){
delete level;
@ -48,6 +53,7 @@ void GameAccount::playCard(){
this->level->upgradeLevel();
}
void GameAccount::win(){
if (this->getScore() < 200){
setScore(getScore() + 50);

View File

@ -13,12 +13,7 @@ public:
GameAccount(string iName);
GameAccount(const GameAccount&) = delete;
GameAccount& operator=(const GameAccount&) = delete;
~GameAccount(){
if(level){
delete level;
level = nullptr;
}
}
~GameAccount();
string getName();
void win();
void lose();
@ -33,4 +28,4 @@ private:
string name;
};
#endif
#endif

View File

@ -66,7 +66,6 @@ Secondary::Secondary(){
Secondary::Secondary(Level* level){
this->setGameAccount(level->getGameAccount());
getGameAccount()->setLevel(level);
}
void Secondary::doubleScore(){
@ -99,7 +98,6 @@ Professional::Professional(){
Professional::Professional(Level* level){
this->setGameAccount(level->getGameAccount());
getGameAccount()->setLevel(level);
}
void Professional::doubleScore(){
@ -132,7 +130,6 @@ Final::Final(){
Final::Final(Level* level){
this->setGameAccount(level->getGameAccount());
getGameAccount()->setLevel(level);
}
void Final::doubleScore(){