Guest User

Untitled

a guest
Apr 20th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <string>
  4. #include <vector>
  5.  
  6. using namespace std;
  7.  
  8. class Ship
  9. {
  10. private:
  11. string words;
  12. int nrOfWords;
  13. public:
  14. Ship()
  15. { nrOfWords = 0; }
  16. void addWord(string aWord)
  17. {words = aWord;}
  18. int getNrOfWords() {return nrOfWords;}
  19. string getWords() {return words;}
  20.  
  21.  
  22. };
  23.  
  24.  
  25.  
  26.  
  27. int main()
  28. {
  29. const int Nr = 3;
  30. Ship play[Nr];
  31.  
  32.  
  33.  
  34. vector<string> Words;
  35. string Word;
  36. string ord;
  37. {
  38. cout << "First cargo: ";
  39. getline(cin, Word);
  40. play[1].addWord(Word);
  41. system("cls");
  42.  
  43. cout << "The cargo is:\n";
  44. for (int count = 0; count < Nr; count++)
  45. {
  46. cout<<play[count].getWords() << endl;
  47. }
  48. system("pause");
  49. system("cls");
  50.  
  51. bool done = false;
  52. while(!done)
  53. {
  54. cout <<"Repeat the cargo: " << endl;
  55. getline (cin, ord);
  56. for (int count = 0; count < Nr; count++)
  57. {
  58. play[count].addWord(ord);
  59. }
  60. if(play[0].getWords().compare(Word) == 0)
  61. {
  62. cout<<"Next word in shipload: ";
  63. getline(cin, Word);
  64. play[0].addWord(Word);
  65. system("pause");
  66. system("cls");
  67.  
  68. cout << "The cargo is:\n";
  69. for (int line = 0; line < Nr; line++)
  70. {
  71. cout << play[line].getWords() << endl;
  72. }
  73. system("pause");
  74. system("cls");
  75. }
  76. else
  77.  
  78. {
  79. cout<<"Sorry! You did not manage to repeat all the words this time.";
  80. done = true;
  81. }
  82. }
  83.  
  84.  
  85. }
  86.  
  87. return 0;
  88. }
Add Comment
Please, Sign In to add comment