Permalink
Cannot retrieve contributors at this time
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?
adventure-game/Ceesay.cpp
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
61 lines (52 sloc)
1.26 KB
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
#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; | |
} |