Guest User

Untitled

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