Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
#include <iostream>
#include <string>
using namespace std;
class player
{
string playerClass;
int level;
int attack;
public:
int hp;
int mp;
int experience;
player(int choice) {
if (choice ==1) {playerClass = "Warrior";
level = 1;
attack = 60;
hp = 100;
mp = 10;
experience = 0;
}
if (choice == 2) {playerClass = "Wizard";
level = 1;
attack = 20;
hp = 100;
mp = 100;
experience = 0;
}
if (choice == 3) {playerClass = "Archer";
level = 1;
attack = 40;
hp = 100;
mp = 30;
experience = 0;
}
}
string printClass() {
return playerClass;
}
};
int main() {
cout << "choose your character class. \n[1] Warrior [2] Wizard [3] Archer ; ";
int choice;
cin>>choice;
while (!cin >> choice || choice > 3 || choice < 1) {
cout << "Not a valid choice. \nChoose your character class. \n[1] Warrior [2] Wizard [3] Archer : ";
}
player character(choice);
cout << "\nwelcome " << character.printClass() << ".Let's begin your adventure. " <<endl;
cin.ignore();
cin.get();
return 0;
}