C++4日目
1541 ワード
今日必ず言わなければならないのはラウンド制ゲームのダブル対戦で、一人一人が最初から一定の技能を与えて、いくつかのラウンドを経て戦後勝負を決めることができます.
このゲームはあまりにも派手で、コード量が多くなく、いくつかのクラスを簡単に構築しただけで、論理も複雑ではありませんが、分析するととても面白いです.次はいくつかです.hファイル、貼り付けて、構想を整理します
このゲームはあまりにも派手で、コード量が多くなく、いくつかのクラスを簡単に構築しただけで、論理も複雑ではありませんが、分析するととても面白いです.次はいくつかです.hファイル、貼り付けて、構想を整理します
#ifndef MANAGE_H
#define MANAGE_H
#include "skill.h"
class Manage
{
public:
Manage(uint num=0,Skill *skill =NULL);
void addSkill();
Skill *getSkill();
void show();
private:
uint m_uiNum;
Skill *m_pFirstSkill;
};
#endif
#ifndef PLAYER_H
#define PLAYER_H
#include "manage.h"
class Player
{
public:
Player(string name = "npc", uint blood = 1000,uint skillnum=0);
bool isLost();
void showWin();
void showLost();
const string &getName();
uint getBlood();
void attack(Player &other);
uint beAttacked(uint attack);
private:
string m_strName;
uint m_uiBlood;
Manage m_manage;
};
#endif
#ifndef SKILL_H
#define SKILL_H
#include
#include
using namespace std;
typedef unsigned int uint;
class Skill
{
public:
Skill(string name = "unarmed", uint attack = 10);
uint getAttack();
const string &getName();
Skill *m_pNext;
private:
string m_strName;
uint m_uiAttack;
};
#endif