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 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
|
#include <iostream>
#include "movie.h"
#include "Account.h"
#include <string>
using namespace std;
int main()
{
//create 10 movie objects
//name, date, genre, not rented, cost($ per day)
movie title1("The Shawshank Redemption", 1994, "drama", 0, 5);
movie title2("Pulp Fiction", 1994, "drama", 0, 5);
movie title3("Fight Club", 1999, "drama", 0, 5);
movie title4("Star Wars: Episode V - The Empire Strikes Back", 1980, "sci-fi", 0, 5);
movie title5("Goodfellas", 1990, "drama", 0, 4);
movie title6("The Matrix", 1999, "sci-fi", 0, 4);
movie title7("Se7en", 1995, "mystery", 0, 4);
movie title8("The Silence of the Lambs", 1991, "drama", 0, 4);
movie title9("Leon: The Professional", 1994, "drama", 0, 3);
movie title10("American History X", 1998, "drama", 0, 3);
//create an array storing these 10 movie objects
//create array of all movie titles/objects
movie arraymovie[10] = { title1, title2, title3, title4, title5, title6, title7, title8, title9, title10 };
//account object
//Account name, ID, Balance ($)
Account newaccount("User1", 12345, 100);
//create a function to display the list of movies that are available to be rented
//i.e.those that have not been rented
//Enter while loop
while (true)
{
int menu = 0;
int i = 0;
int temp = 0;
int movie = 0;
cout << "Your balance is $" << newaccount.getbalance() << endl;
cout << "Select 1 to rent a movie \n";
cout << "Select 2 to return a movie \n";
cout << "Select 3 to view my account \n";
cout << "Select 4 to exit \n";
cin >> temp;
/*make sure the user input choice is a valid integer
if the movie is available to be rented, then ask how many days would you like to rent the movie
using the cost of that particular movie object, calculate the total cost
if the balance of the account is sufficient, then deduct the cost from the balance and update the status of the movie
else, say "sorry, you do not have enough money to rent movie X for Y days"*/
//display menu
//get the input from the user
//based on the input, perform the action in the menu
//display 4 choices
switch (temp)
{
case 1: //1.) Rent Movie - see case 1 below
{
cout << "Select a movie to rent";
for (i = 0; i <= 9; i++)
{
cout << arraymovie[i].getname_of_movie();
int movie_choice = 0;
cin >> movie_choice;
arraymovie[movie_choice].setis_the_movie_rented_or_not(1);
cout << "Is this correct? Enter 'yes' or 'no'";
}
int movie_choice = 0;
cin >> movie_choice;
if ("yes")
arraymovie[movie_choice].setis_the_movie_rented_or_not(1);
else ("no");
break;
cout << "Thank you for renting " << arraymovie[i].getname_of_movie() << ", you have 24 hours to return the movie.";
break;
}
case 2: //2.) Return Movie - update the status of the movie being returned
{
for(i = 0; i <= 9; i++)
//if(arraymovie[i] == false)
break;
}
case 3: //3.) Check Account - list which movies are being rented and display balance of account
{
cout << "User1";
cout << "ID#: 12345";
cout << "Current balance: $";
break;
}
case 4: //4.) Exit
{
break;
}
default:
{
"Please select 1, 2, 3, or 4 as your command.";
break;
}
}
}
cin.get();
cin.get();
}
| |