Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <string>
- #include <vector>
- using namespace std;
- class Ship
- {
- private:
- string words;
- int nrOfWords;
- public:
- Ship()
- { nrOfWords = 0; }
- void addWord(string aWord)
- {words = aWord;}
- int getNrOfWords() {return nrOfWords;}
- string getWords() {return words;}
- };
- int main()
- {
- const int Nr = 3;
- Ship play[Nr];
- vector<string> Words;
- string Word;
- string ord;
- {
- cout << "First cargo: ";
- getline(cin, Word);
- play[1].addWord(Word);
- system("cls");
- cout << "The cargo is:\n";
- for (int count = 0; count < Nr; count++)
- {
- cout<<play[count].getWords() << endl;
- }
- system("pause");
- system("cls");
- bool done = false;
- while(!done)
- {
- cout <<"Repeat the cargo: " << endl;
- getline (cin, ord);
- for (int count = 0; count < Nr; count++)
- {
- play[count].addWord(ord);
- }
- if(play[0].getWords().compare(Word) == 0)
- {
- cout<<"Next word in shipload: ";
- getline(cin, Word);
- play[0].addWord(Word);
- system("pause");
- system("cls");
- cout << "The cargo is:\n";
- for (int line = 0; line < Nr; line++)
- {
- cout << play[line].getWords() << endl;
- }
- system("pause");
- system("cls");
- }
- else
- {
- cout<<"Sorry! You did not manage to repeat all the words this time.";
- done = true;
- }
- }
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment