1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
#include <iostream>
#include <conio.h>
#include <string>
#include <windows.h>
#define K1 49
#define K2 50
#define K3 51
using namespace std;
class Character {
public:
string type;
string name;
float HP;
float MP;
float str;
float def;
float agility;
int LVL;
Character(string atype, string aname, float aHP, float aMP, float astr, float adef, float aagility, int aLVL) {
type = atype;
name = aname;
HP = aHP;
MP = aMP;
str = astr;
def = adef;
agility = aagility;
LVL = aLVL;
}
};
class Chosen : public Character {
public:
using Character::Character;
};
int main()
{ // an empty charactere
Character who("Class", "Name", 0, 0, 0, 0, 0, 0);
Character war("Warrior", "Achilles", 100, 30, 50, 35, 30, 1);
Character nin("Assassin", "Jin Sakai", 80, 50, 50, 30, 50, 1);
Character mag("Wizard", "Merlin", 60, 100, 40, 25, 20, 1);
cout << "Press 1 for warrior\tPress 2 for Assassin\tPress 3 for wizard\n";
string chosenChar;
switch (_getch())
{
case K1:
{
chosenChar = war.type;
cout << "You have chosen the " << chosenChar << endl;
Chosen chosenOne("Warrior", "Achilles", 100, 30, 50, 35, 30, 1);
who = chosenOne; // clone the chosen one
break;
}
case K2:
{
chosenChar = nin.type;
cout << "You have chosen the " << chosenChar << endl;
Chosen chosenOne("Assassin", "Jin Sakai", 80, 50, 50, 30, 50, 1);
who = chosenOne; // clone the chosen one
break;
}
case K3:
{
chosenChar = mag.type;
cout << "You have chosen the " << chosenChar << endl;
Chosen chosenOne("Wizard", "Merlin", 60, 100, 40, 25, 20, 1);
who = chosenOne; // clone the chosen one
break;
}
}
cout << "Some player features : " << endl
<< who.type << endl
<< who.name << endl
<< who.HP << endl;
return 0;
}
|