Question

In: Computer Science

Write a program to manage DVD rental in a video rental store. Create an abstract data...

Write a program to manage DVD rental in a video rental store. Create an abstract data type that represents a DVD in this store. Consider all the data and operations that may be necessary for the DVD type to work well within a rental management system. Include a print() member function that displays all the information about the DVD. Test your data type by creating an array of ten DVD instances and filling them using information read from a test input file that you create. Display the DVD information. Language C++.

Solutions

Expert Solution

Ans:

//INPUT file named "sample.txt" used -

Drama/Crime R 1972 11/12/2016 11/15/2016 The_Godfather
Drama/Thriller PG 2008 12/20/2016 12/25/2016 The_Dark_Knight
Mystery R 1960 10/15/2016 10/20/2016 Psycho
SIFI PG 2010 08/02/2016 08/07/2016 Inception
Drama U/A 1997 08/09/2016 08/14/2016 Titanic
Fantasy U/A 2003 08/09/2016 08/14/2016 The_Lord_Of_The_Rings
Drama R 1994 08/09/2016 08/14/2016 The_Shashank_Redemption
Drama/Sport PG 1976 07/01/2016 07/08/2016 Rocky
Adventure 1993 07/01/2016 07/08/2016 Jurassic_Park
Horror R 1973 07/01/2016 07/08/2016 The_Exorcist

// for the program to work correctly copy the above data in a file named sample.txt in the following manner!

// the required program for managing a DVD rental in a video rental store

#include <iostream>
#include <string>
#include <fstream>
using namespace std;
// the abstraction of a DVD class being used here
class DVD
{ string genre;
string type;
string year;
string dateRented;
string dateReturned;
string title;
public:
// various methods which may separately used for updating the respective fields
void setName (string z) {
title = z;
}
string getName(){
return title;
}

void setmovierating (string w) {
type = w;
}
string getmovierating (){
return type;
}
void setyear (string v){
year = v;
}
string getyear (){
return year;
}
void setdateRented (string u) {
dateRented = u;
}
string getdateRented (){
return dateRented;
}
void setdateReturned (string t) {
dateReturned = t;
}
string getdateReturned (){
return dateReturned;
}   
void setmoviegenre (string t) {
genre = t;
}
string getmoviegenre (){
return genre;
}
// Read one DVD from the input file
// Assumes one the mentioned set of fields in their respective orders per line in input file
bool Read (istream & is)
{   
is >> genre >> type >> year >> dateRented >> dateReturned >> title;
return is.good();
}
  
// Print one DVD
void Print (ostream & os) const
{ os << "Name: " << title << endl;
os << "Genre: " << genre << endl;
os << "Rated: " << type << endl;
os << "Date Released: " << year << endl;
os << "Date Rented: " << dateRented << endl;
os << "Date Returned: " << dateReturned << endl;
os << endl;
}

};

int main()
{ DVD a[10];
// using an ifstream object from the fstream library
ifstream dvdfile ("sample.txt"); // Declare and open the file of DVDs
int ent = 1; // for holding the current state of choice for a user
do{
       //Menu
       cout<<"----------------------------------";
       cout<<"\nSimple DVD Rental Management System";
       cout<<"\n----------------------------------";
       cout<<"\nWelcome Customer!";   //Menu for the user
       cout<<"\n\n\t <1> Display Rental Records";
       cout<<"\n\t <2> Exit \n\n";
       cout<<"Enter Your Choice :"<<"\t";
       cin>>ent;
   switch(ent)
   {
   case 1:
{
for(int i = 0; i<10; i++)
a[i].Read (dvdfile); // Read one DVD from the file
for(int i = 0; i<10; i++)   
a[i].Print (cout); // Print one DVD
  
cout << " These are the required records ! "<<endl;
ent = 0;
break;
  
}
  
default:
ent = 0;
break;
   }
  
}while(ent);
  
return 0;
}

OUTPUT:

// PLEASE DO LIKE AND UPVOTE IF THIS WAS HELPFUL!

// THANK YOU SO MUCH IN ADVANCE!


Related Solutions

Rental Shop A. Create an abstract class named SummerSportRental that is to be used with for...
Rental Shop A. Create an abstract class named SummerSportRental that is to be used with for a summer sports rental shop. The SummerSportRental class must have the properties of newModel which takes on the type boolean, and rentalCost which takes on the type double, and rentalNumber which is an identification number as an long integer.These member variables must all be private! It also must include the following member functions: 1. equals() which returns true if two SummerSportRental objects have the...
You are asked to create to to-do list program to store and manage to-do items for...
You are asked to create to to-do list program to store and manage to-do items for user. You need to define a class to-do item which holds the following attributes: • Id => number, generated by the program when item is created • Title => string • Description => string • Type (e.g. shopping, housing, work, etc.) => Enum • Priority => number between 1 to 5 • Status => (e.g. done, in progress, hold, etc.) => Enum • Create...
Atlantic Video, a small video rental store in Philadelphia, is open 24 hours a day, and—due...
Atlantic Video, a small video rental store in Philadelphia, is open 24 hours a day, and—due to its proximity to a major business school—experiences customers arriving around the clock. A recent analysis done by the store manager indicates that there are 20 customers arriving every hour, with a standard deviation of interarrival times of 2 minute(s). This arrival pattern is consistent and is independent of the time of day. The checkout is currently operated by one employee, who needs on...
Atlantic Video, a small video rental store in Philadelphia, is open 24 hours a day, and—due...
Atlantic Video, a small video rental store in Philadelphia, is open 24 hours a day, and—due to its proximity to a major business school—experiences customers arriving around the clock. A recent analysis done by the store manager indicates that there are 10 customers arriving every hour, with a standard deviation of interarrival times of 1 minute(s). This arrival pattern is consistent and is independent of the time of day. The checkout is currently operated by one employee, who needs on...
write a java program that implements the splay tree data structure for the dictionary abstract data...
write a java program that implements the splay tree data structure for the dictionary abstract data type. Initially the program reads data from "in.dat", and establishes an ordinary binary search tree by inserting the data into the tree. The data file contains integers, one per line. in.dat file contents: 3456 5678 1234 2369 7721 3354 1321 4946 3210 8765 Then the program starts an interactive mode. The commands are as follows. S 1000 - splay the tree at 1000 F...
You are to create a program to request user input and store the data in an...
You are to create a program to request user input and store the data in an array of structures, and then display the data as requested. The data you are collecting refers to a set of images. The images are OCT images taken of the lining of the bladder. The data you provide will help diagnose the image as cancerous or not, but your code does not need to do that at the moment. First, Define a global structure that...
You are to create a program to request user input and store the data in an...
You are to create a program to request user input and store the data in an array of structures, and then display the data as requested. The data you are collecting refers to a set of images. The images are OCT images taken of the lining of the bladder. The data you provide will help diagnose the image as cancerous or not, but your code does not need to do that at the moment. 1) Define a global structure that...
Write a Java program to process the information for a bank customer.  Create a class to manage...
Write a Java program to process the information for a bank customer.  Create a class to manage an account, include the necessary data members and methods as necessary.  Develop a tester class to create an object and test all methods and print the info for 1 customer.  Your program must be able to read a record from keyboard, calculate the bonus and print the details to the monitor.  Bonus is 2% per year of deposit, if the amount is on deposit for 5 years...
In C: You are to create a program to request user input and store the data...
In C: You are to create a program to request user input and store the data in an array of structures, and then display the data as requested. The data you are collecting refers to a set of images. The images are OCT images taken of the lining of the bladder. The data you provide will help diagnose the image as cancerous or not, but your code does not need to do that at the moment. 1) Define a global...
Write a program that does the following in C++ 1 ) Write the following store data...
Write a program that does the following in C++ 1 ) Write the following store data to a file (should be in main) DC Tourism Expenses 100.20 Revenue 200.50 Maryland Tourism Expenses 150.33 Revenue 210.33 Virginia Tourism Expenses 140.00 Revenue 230.00 2 ) Print the following heading: (should be in heading function) Store name | Profit [Note: use setw to make sure all your columns line up properly] 3 ) Read the store data for one store (should be in...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT