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 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
|
#include <iostream>
#include <stdlib.h>
#include <string>
#include <vector>
using namespace std;
class Characters{
private:
int health, armor, attack, speed, regen;
public:
virtual void SetValues();
void getValues();
int GetAttackDamage();
int GetHealth();
int GetArmor();
int GetAttack();
int GetSpeed();
int GetRegen();
};
class Monsters:public Characters{
vector<Characters *> chars;
vector<Characters *>::iterator it;
void NewMonster();
void selectMonster();
void EditMonster();
public:
int menu();
};
void Monsters::NewMonster(){
int select;
Characters * chars;
}
void Characters::SetValues()
{
cout << "\nEnter Health Value: ";
std::cin >> health;
cout << "\nEnter Armor Value: ";
std::cin >> armor;
cout << "\nEnter Attack Value: ";
std::cin >> attack;
cout << "\nEnter Speed Value: ";
std::cin >> speed;
cout << "\nEnter Regen Value: ";
std::cin >> regen;
}
void Monsters::selectMonster()
{ // Function of a class.
int select, i = 1;
it = chars.begin(); // Set the iterator to the beginning of the vector.
while (it != chars.end()){ // Until the end of the vector,
cout << i << ". "; // Print the number for a line,
(*it)->SetValues(); //Set Values
++it; // Go to the next item in the list,
++i; // And finally, make the next line the next number
}
cout << " "; // User shell input prompt
cin >> select; // Get input from the user
it = chars.begin(); // Set the iterator to the beginning of the vector.
//advance(it, chars - 1); // Move the iterator to the item selected by the user. It's (sel - 1) because vectors start at 0, and the list as printed starts at 1.
}
int Characters::GetAttackDamage()
{
return{ attack * speed };
}
int Characters::GetHealth()
{
return health;
}
int Characters::GetArmor()
{
return armor;
}
int Characters::GetAttack()
{
return attack;
}
int Characters::GetSpeed()
{
return speed;
}
int Characters::GetRegen()
{
return regen;
}
int main()
{
int option; // user's entered option will be saved in this variable
do //do-while loop starts here.that display menu again and again until user select to exit program
{
//Displaying Options for the menu
cout << "1) Create New Hunter " << endl;
cout << "2) Create New Monster " << endl;
cout << "3) Display Hunters" << endl;
cout << "4) Dispaly Monsters " << endl;
cout << "5) Terminate Program " << endl;
//Prompting user to enter an option according to menu
cout << "Please select an option : ";
cin >> option; // taking option value as input and saving in variable "option"
if (option == 1) // Checking if user selected option 1
{
//Create New Charcters
cout << " New Hunter created, enter stats:";
}
else if (option == 2) // Checking if user selected option 2
{
//Create New Monster
Monsters mOne;
mOne.SetValues();
system("pause");
}
else if (option == 3) // Checking if user selected option 3
{
//Display Characters
}
else if (option == 4) //Checking if user selected option 4
{
//Display Monsters
}
else if (option == 5) //Dispaly Monsters
{
cout << "Terminating Program" << endl;
}
else //if user has entered invalid choice (other than 1,2,3,4 or 5)
{
//Displaying error message
cout << "Invalid Option entered" << endl;
}
} while (option != 5); //condition of do-while loop
return 0;
}
|