From 68d7e65e2bb6a93c3083be3abc7552e39689de4b Mon Sep 17 00:00:00 2001 From: Alexander Zhirov Date: Mon, 13 Sep 2021 17:35:30 +0300 Subject: [PATCH] lesson_65 --- lesson_65/main.cpp | 63 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 lesson_65/main.cpp diff --git a/lesson_65/main.cpp b/lesson_65/main.cpp new file mode 100644 index 0000000..a27e3d8 --- /dev/null +++ b/lesson_65/main.cpp @@ -0,0 +1,63 @@ +/* + * main.cpp + * + * Created on: 13 сент. 2021 г. + * Author: alexander + */ +#include +#include + +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; +} +