Merge pull request #9 from sterben-01/master

fix bug
master
Qiangguo Feng 2022-10-17 16:17:42 +08:00 committed by GitHub
commit 05094c223e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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(){