1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
/* By implementing this correctly and integrating it into your
* project so that movie names are displayed with spaces, even
* though the user enters them without spaces you can earn
* some additional extra credit.
*
* Breaks up a string at capital letters and inserts spaces
* So if the input is "IHaveADream" return "I Have A Dream".
* You may assume the first letter is a caps (and even if it
* not you will still get a reasonable result; so "badNews"
* should still return "bad News").
*
* Parameters:
* in: string with no spaces
*
* Return a version of the string with spaces
*/
string breakStringAtCaps(string in);
string breakStringAtCaps(string in)
{
/* !!!!!!!! Implement this for extra credit if you desire !!!!! */
/* Otherwise leave this as is
*/
return in;
}
/**********************************************************
* Main must be completed by you.
**********************************************************/
int main()
{
const int SIZE = 20;
string movies[SIZE];
int ratings[SIZE];
int numMovies = 0;
string name;
int rating;
int selection;
//do while loop will execute while the selection the user inputs is in between 1 and 4
do
{
int selection = printPromptAndGetInput();
if(selection == 1)
{
cout << "Enter movie name and rating"<<endl;
cin >> name;
cin >> rating;
insertMovie(movies, ratings, name, rating, numMovies);
numMovies++;
}
else if(selection == 2)
{
cout << "Enter the movie name and the updated rating" << endl;
rateMovie(movies, ratings, name, rating, numMovies);
}
else if(selection == 3)
{
cout << "Enter the name of the movie you wish to delete" << endl;
deleteMovie(movies, ratings, name, numMovies);
numMovies--;
}
else if(selection == 4)
{
sortList(movies, ratings, numMovies);
printList(movies, ratings, numMovies);
}
}while(selection >= 1 || selection < 5);
return 0;
}
|