Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main()
- {
- void WaitForEnter();
- void printArray(string array1[4], int array2[4], int array3[4], string array4[4]);
- string name[4];
- int clazz[4];
- string clazzTypes[4] = {"Java Programmer", "C++ Programmer", "Ruby Programmer", "Polyglot"};
- int strength[4] = {10, 3, 11, 100};
- cout << "Welcome, this is a traditional RPG\n"
- << "You know like Chrono Trigger, or Lufia II.\n"
- << "You will be facing many hardships, but fear not,\n"
- << "you will not be alone, you will travel in a party of four.\n"
- << "Anyhow if you would be so kind, \n";
- for(int i=0; i<4;i++)
- {
- //Character name
- cout << "Please choose a name for party member " << i+1 << ": ";
- getline(cin, name[i]);
- while(name[i].empty())
- {
- cin.clear();
- cin.ignore();
- cout << "please choose a name for party member " << i+1 << ": ";
- getline(cin, name[i]);
- }
- cout << "You entered " << name[i] <<"\n";
- //Character class
- cout << "Please choose a class for party member " << i+1 <<": \n"
- << "1 - Java Programmer\n "
- << "2 - C++ Programmer\n "
- << "3 - Ruby Programmer\n"
- << "4 - Polyglot\n"
- << "Select 1-4: ";
- cin >> clazz[i];
- while(clazz[i] < 1 || clazz[i] >4) { cin.clear(); cin.ignore(); cout << "Please enter a number between 1-4:"; cin >>clazz[i]; }
- cin.ignore();
- }
- printArray(name, clazz, strength, clazzTypes);
- cout << "\nPress enter to quit.\n";
- WaitForEnter();
- }
- void WaitForEnter()
- {
- while ( 1 ) { if ( '\n' == getchar() ) { break; } }
- }
- void printArray(string names[4], int clazzIndex[4], int strength[4], string clazzes[4])
- {
- cout << "*****************************" << endl
- << "*******Party Members:********" << endl;
- for (int i=0; i<4; i++)
- {
- cout << "Name: " << names[i] <<endl;
- cout << "Class: " << clazzes[clazzIndex[i]-1] <<endl;
- cout << "Strength: " <<strength[clazzIndex[i]-1] <<endl <<endl;
- }
- cout << "*****************************" << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement