Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
1 changed file
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#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; | ||
} |