lesson_65

This commit is contained in:
Alexander Zhirov 2021-09-13 17:35:30 +03:00
parent e280a4648d
commit 68d7e65e2b
1 changed files with 63 additions and 0 deletions

63
lesson_65/main.cpp Normal file
View File

@ -0,0 +1,63 @@
/*
* 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;
}