Skip to content

Instantly share code, notes, and snippets.

@ohmiyaji
Last active March 13, 2018 07:19
Show Gist options
  • Save ohmiyaji/0bc917f687fcec2bc824a83d17a66cf7 to your computer and use it in GitHub Desktop.
Save ohmiyaji/0bc917f687fcec2bc824a83d17a66cf7 to your computer and use it in GitHub Desktop.
gameclass.cpp
class Game{
Mao m;
Hero h;
void Ending()const;
public:
Game();
void Play();
};
Game::Game(){
cout << "これから魔王と戦います。がんばれ!" << endl;
cout << "魔王の残りエネルギー:" << m.GetEnergy();
}
void Game::Ending()const{
cout << "さあ、ゲームはおしまいです。" << endl;
}
void Game::Play(){
while(h.GetEnergy()>0){
if(m.GetEnergy()<=0){
break;
}
m.Attaked(h.Attack());
}
if(m.GetEnergy()>0){
cout << "・・・魔王は逃げてしまった。" << endl;
}
Ending();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment