C++ Using an enumeration set and if statements to set multiple types of enemy's Damage an integer(idamage) and print to console what enemy they choose and what damage it does ,ive put a do while loop , so they can check as many enemys damage as they want until the enter 10 to exit {#include
include
enum Difficulty { UNDEAD, GREMLIN, WAREWOLF, NIGHTSTALKERS, FINKS, PANTHERS, ORKS, NATIVES, CLUBS, OGRE
};
int main(int argc, char* argv[]) {
char cEnemytypes[10][14] = { "UNDEAD", "GREMLIN", "WAREWOLF", "NIGHTSTALKERS", "FINKS", "PANTHERS", "ORKS", "NATIVES", "CLUBS", "OGRE" };
int iChoice;
int iDamage = 0;
for (int i = 0; i < 9; i++)
std::cout << cEnemytypes[i] << std::endl;
std::cout << "press 10 to exit " << std::endl;
std::cout << "enter a number form 0- 9 or 10 to exit " << std::endl;
do {
std::cin >> iChoice;
if ((iChoice = UNDEAD)&&(iChoice < WAREWOLF) ){
iDamage = 5;
}
if ((iChoice = WAREWOLF) && (iChoice < FINKS)){
iDamage = 10;
}
if ((iChoice = FINKS) && (iChoice < NATIVES)){
iDamage = 15;
}
if ((iChoice = NATIVES) && (iChoice < 10)){
iDamage = 20;
}
std::cout << "the " << cEnemytypes[iChoice] << " does " << iDamage << " points in damage" << std::endl;
} while (iChoice != 10);
std::cout << "exiting program now"<< std::endl;
system("pause");
return 0;
}}
Aucun commentaire:
Enregistrer un commentaire