|
Post by D33P on May 9, 2015 23:47:08 GMT -5
My program, which lets you make monsters with names, types, and health:
#include "stdafx.h" #include <iostream> #include <string> using namespace std; enum class Type { ogre = 1, dragon, orc, giant, spider, slime }; struct Monster { Type type; string name; int health; }; string GetType(Monster monster) { switch (static_cast<int>(monster.type)) { case 1: return "ogre"; case 2: return tragon"; case 3: return "orc"; case 4: return "giant"; case 5: return "spider"; case 6: return "slime"; default: return "unknown"; } } void PrintMonster(Monster monster) { cout << "This " << GetType(monster) << " is named " << monster.name << " and has " << monster.health << " health." << endl; } int main() { Monster gg = { Type::ogre, "gg", 69 }; Monster gf = { Type::slime, "gf", 420 }; PrintMonster(gg); PrintMonster(gf); return 0; }
|
|
|
Post by Toast on May 10, 2015 11:04:46 GMT -5
"gg", 69 "gf", 420
|
|
Blaze
FTL
Always remember that you are absolutely unique. Just like everyone else.
Posts: 120
|
Post by Blaze on May 11, 2015 16:12:54 GMT -5
Where can u lern C++?
|
|
|
Post by D33P on May 11, 2015 16:59:39 GMT -5
|
|
Blaze
FTL
Always remember that you are absolutely unique. Just like everyone else.
Posts: 120
|
Post by Blaze on May 11, 2015 19:43:17 GMT -5
So if I do all of the tutorials, can I become a pr0 pr0gramer?
|
|
rad
FTL
Posts: 46
|
Post by rad on May 24, 2015 19:19:56 GMT -5
Finally got around to doing the Ch. 4 Quiz.
|
|