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; +} +