64 lines
1001 B
C++
64 lines
1001 B
C++
/*
|
||
* main.cpp
|
||
*
|
||
* Created on: 13 сент. 2021 г.
|
||
* Author: alexander
|
||
*/
|
||
#include <iostream>
|
||
#include <string>
|
||
|
||
enum class Race
|
||
{
|
||
OGRE, GOBLIN, SKELETON, ORC, TROLL,
|
||
};
|
||
|
||
struct Monster
|
||
{
|
||
Race type;
|
||
std::string name;
|
||
int health;
|
||
};
|
||
|
||
void printMonster(Monster &m)
|
||
{
|
||
std::cout << "This ";
|
||
|
||
if (m.type == Race::OGRE)
|
||
{
|
||
std::cout << "Ogre";
|
||
}
|
||
else if (m.type == Race::GOBLIN)
|
||
{
|
||
std::cout << "Goblin";
|
||
}
|
||
else if (m.type == Race::SKELETON)
|
||
{
|
||
std::cout << "Skeleton";
|
||
}
|
||
else if (m.type == Race::ORC)
|
||
{
|
||
std::cout << "Orc";
|
||
}
|
||
else if (m.type == Race::TROLL)
|
||
{
|
||
std::cout << "Troll";
|
||
}
|
||
|
||
std::cout << " is named " << m.name << " and has " << m.health << " health."
|
||
<< std::endl;
|
||
}
|
||
|
||
int main()
|
||
{
|
||
Monster john
|
||
{ Race::GOBLIN, "John", 170 };
|
||
Monster james
|
||
{ Race::ORC, "James", 35 };
|
||
|
||
printMonster(john);
|
||
printMonster(james);
|
||
|
||
return 0;
|
||
}
|
||
|