Last active
December 22, 2015 11:48
-
-
Save KoaxialKable/6467573 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
using namespace std; | |
struct hero | |
{ | |
string name; | |
string job; | |
int str; | |
} ; | |
hero party[4]; | |
string input; | |
void getAll() | |
{ | |
for (int i=0; i<4; i++) | |
{ | |
// name | |
cout << "\nPlease give me a name for character " << i+1 << ": "; | |
getline(cin, input); | |
party[i].name = input; | |
// class | |
cout << "Please select a class:\n"; | |
cout << "\t1: Fighter\n"; | |
cout << "\t2: Mage\n"; | |
cout << "\t3: Thief\n"; | |
cout << "> "; | |
getline(cin, input); | |
// based on class, generate strength | |
switch (input[0]) | |
{ | |
case '1': party[i].job = "Fighter"; | |
party[i].str = 6; | |
break; | |
case '2': party[i].job = "Mage"; | |
party[i].str = 2; | |
break; | |
case '3': party[i].job = "Thief"; | |
party[i].str = 4; | |
break; | |
default: party[i].job = "Fighter"; | |
party[i].str = 6; | |
break; | |
} | |
} | |
} | |
void printAll() | |
{ | |
cout << "Let's see here...\n\n"; | |
for (int i = 0; i < 4; i++) | |
{ | |
cout << "Character " << i+1 << "'s name is: " << party[i].name << ".\n"; | |
cout << party[i].name << "'s class is: " << party[i].job << ".\n"; | |
cout << party[i].name << "'s strength is: " << party[i].str << ".\n\n"; | |
} | |
} | |
int main () | |
{ | |
cout << "You get a party of four RPG characters!\n\n"; | |
getAll(); | |
printAll(); | |
getline(cin, input); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment