Guest User

Untitled

a guest
Apr 20th, 2018
88
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; aWord +=nrOfWords;}
  18. int getNrOfWords() {return nrOfWords;}
  19. string getWords() {return words;}
  20.  
  21. };
  22.  
  23.  
  24.  
  25.  
  26. int main()
  27. {
  28. vector<string> Words;
  29. string Word;
  30. string ord;
  31. {
  32. cout << "First cargo: ";
  33. getline(cin, Word);
  34. string in(Word);
  35. Words.push_back(in);
  36. system("cls");
  37.  
  38. cout << "The cargo is:\n";
  39. for (int count = 0; count < Words.size(); count++)
  40. {
  41. cout << Words[count] << endl;
  42. }
  43. system("pause");
  44. system("cls");
  45.  
  46. bool done = false;
  47. while(!done)
  48. {
  49. cout <<"Repeat the cargo: " << endl;
  50. for (int count = 0; count < Words.size(); count++)
  51. getline (cin, ord);
  52. string temp(ord);
  53. if(temp.compare(Word) == 0)
  54. {
  55. cout<<"Next word in shipload: ";
  56. getline(cin, Word);
  57. string in(Word);
  58. Words.push_back(in);
  59. system("pause");
  60. system("cls");
  61.  
  62. cout << "The cargo is:\n";
  63. for (int count = 0; count < Words.size(); count++)
  64. {
  65. cout << Words[count] << endl;
  66. }
  67. system("pause");
  68. system("cls");
  69. }
  70. else
  71. {
  72. cout<<"Sorry! You did not manage to repeat all the words this time.";
  73. done = true;
  74. }
  75. }
  76.  
  77. }
  78.  
  79. return 0;
  80. }
Add Comment
Please, Sign In to add comment