Advertisement
zCool

Party Creation

May 5th, 2012
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.98 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. void WaitForEnter();
  8. void printArray(string array1[4], int array2[4], int array3[4], string array4[4]);
  9. string name[4];
  10. int clazz[4];
  11. string clazzTypes[4] = {"Java Programmer", "C++ Programmer", "Ruby Programmer", "Polyglot"};
  12. int strength[4] = {10, 3, 11, 100};
  13.  
  14. cout << "Welcome, this is a traditional RPG\n"
  15.      << "You know like Chrono Trigger, or Lufia II.\n"
  16.      << "You will be facing many hardships, but fear not,\n"
  17.      << "you will not be alone, you will travel in a party of four.\n"
  18.      << "Anyhow if you would be so kind, \n";
  19.    
  20.  
  21. for(int i=0; i<4;i++)
  22. {  
  23.     //Character name
  24.     cout << "Please choose a name for party member " << i+1 << ": ";
  25.     getline(cin, name[i]);
  26.     while(name[i].empty())
  27.     {
  28.         cin.clear();
  29.         cin.ignore();
  30.         cout << "please choose a name for party member " << i+1 << ": ";
  31.         getline(cin, name[i]);
  32.     }
  33.  
  34.     cout << "You entered " << name[i] <<"\n";
  35.  
  36.     //Character class
  37.     cout << "Please choose a class for party member " << i+1 <<": \n"
  38.              << "1 - Java Programmer\n "
  39.              << "2 - C++ Programmer\n "
  40.              << "3 - Ruby Programmer\n"
  41.              << "4 - Polyglot\n"
  42.              << "Select 1-4: ";
  43.  
  44.     cin >> clazz[i];
  45.     while(clazz[i] < 1 || clazz[i] >4) { cin.clear(); cin.ignore(); cout << "Please enter a number between 1-4:";  cin >>clazz[i]; }
  46.  
  47.     cin.ignore();
  48. }
  49.  
  50. printArray(name, clazz, strength, clazzTypes);
  51.  
  52. cout << "\nPress enter to quit.\n";
  53. WaitForEnter();
  54.  
  55. }
  56.  
  57. void WaitForEnter()
  58. {
  59.     while ( 1 ) { if ( '\n' == getchar() ) { break; } }
  60. }
  61.  
  62. void printArray(string names[4], int clazzIndex[4], int strength[4], string clazzes[4])
  63. {
  64.      
  65.     cout << "*****************************" << endl
  66.          << "*******Party Members:********" << endl;
  67.     for (int i=0; i<4; i++)
  68.     {
  69.         cout << "Name: " << names[i] <<endl;
  70.         cout << "Class: " << clazzes[clazzIndex[i]-1] <<endl;
  71.         cout << "Strength: " <<strength[clazzIndex[i]-1] <<endl <<endl;
  72.     }
  73.     cout << "*****************************" << endl;
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement