Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A new DVD store in your neighborhood is about to pen. However, it does not have

ID: 3671206 • Letter: A

Question

A new DVD store in your neighborhood is about to pen. However, it does not have a program to keep track of its DVDs. You have been asked to write a program for their store. The program should be able to perform the following operations:
1. Rent a DVD; that is, check out a DVD

2. Return, or check in a DVD

3. Display a list of DVDs owned by the store

4. Show the details of a particular DVD

5. Check whether a particular DVD is in the store
DVDs have the following information that will need to be stored for each DVD owned by the store: Name of the movie, name of the director, movie rating, number of copies owned by the store.
The following functions must be implemented:
CreateDVDLinkedList– read the data file and create the linked list of DVD nodes.

ShowDVDInformation – given pointer to the node, display the DVD information

DisplayDVDLibrary – given pointer to the first node, display all DVDs owned by the store (tabular form)

FindDVDbyTitle – given pointer to the first node and the title, find and return pointer to the appropriate node in the list or nullptr otherwise

CheckOut – given pointer to the DVD node, decrement number of DVDs currently in the store, if DVD owned by the store and if not 0 already

CheckIn – given pointer to the DVD node, increment number of DVDs currently in the store if DVD owned by the store
Function Prototypes:

void CreateDVDLinkedList(Node* &); // note head pointer is passed by reference void ShowDVDInformation(Node*);

void DisplayDVDLibrary(Node*);

Node* FindDVDbyTitle(Node*, string);

void CheckOut(Node*);

void CheckIn(Node*); void DeleteList(Node*);
Show ERROR messages when movie is not found, when check out cannot be performed because all DVDs are rented out.

Add more movies to your data file so that there is exactly 10 DVDs in it. Name the file lab4.txt. Do not add any more Hobbit DVDs.
Read the data file and create the linked list implementation. Allow the user to select from the following menu of options:
1. Rent a DVD --- user enters title, find DVD, decrement number of DVDs in the store

2. Return a DVD --- user enters title, find DVD, increment number of DVDs in the store

3. Find a DVD – user enters title, find DVD, display all DVD information

4. Listing of all DVDs – produce listing of all DVD data

5. Quit

Explanation / Answer

#include <iostream>
#include <string>
using namespace std;
class dvdType
{
friend ostream& operator<< (ostream&, const dvdType&);
public:
void setDVDInfo(string title, string star1,
string star2, string producer,
string director, string productionCo,
int setInStock);
//Function to set the details of a DVD.
//The member variables are set according to the
//parameters.
//Postcondition: dvdTitle = title; movieStar1 = star1;
// movieStar2 = star2; movieProducer = producer;
// movieDirector = director;
// movieProductionCo = productionCo;
// copiesInStock = setInStock;
int getNoOfCopiesInStock() const;
//Function to check the number of copies in stock.
//Postcondition: The value of copiesInStock is returned.
void checkOut();
//Function to rent a DVD.
//Postcondition: The number of copies in stock is
// decremented by one.
void checkIn();
//Function to check in a DVD.
//Postcondition: The number of copies in stock is
// incremented by one.
void printTitle() const;
//Function to print the title of a movie.
void printInfo() const;
//Function to print the details of a DVD.
//Postcondition: The title of the movie, stars,
// director, and so on are displayed
// on the screen.
bool checkTitle(string title);
//Function to check whether the title is the same as the
//title of the DVD.
//Postcondition: Returns the value true if the title
// is the same as the title of the DVD;
// false otherwise.
void updateInStock(int num);
//Function to increment the number of copies in stock by
//adding the value of the parameter num.
//Postcondition: copiesInStock = copiesInStock + num;
void setCopiesInStock(int num);
//Function to set the number of copies in stock.
//Postcondition: copiesInStock = num;
string getTitle() const;
//Function to return the title of the DVD.
//Postcondition: The title of the DVD is returned.
dvdType(string title = "", string star1 = "",
string star2 = "", string producer = "",
string director = "", string productionCo = "",
int setInStock = 0);
//constructor
//The member variables are set according to the
//incoming parameters. If no values are specified, the
//default values are assigned.
//Postcondition: dvdTitle = title; movieStar1 = star1;
// movieStar2 = star2;
// movieProducer = producer;
// movieDirector = director;
// movieProductionCo = productionCo;
// copiesInStock = setInStock;
//Overload the relational operators.
bool operator==(const dvdType&) const;
bool operator!=(const dvdType&) const;
private:
string dvdTitle; //variable to store the name
//of the movie
string movieStar1; //variable to store the name
//of the star
string movieStar2; //variable to store the name
//of the star
string movieProducer; //variable to store the name
//of the producer
string movieDirector; //variable to store the name
//of the director
string movieProductionCo; //variable to store the name
//of the production company
int copiesInStock; //variable to store the number of
//copies in stock
};

#include <string>
#include "unorderedLinkedList.h"
#include "dvdType.h"
using namespace std;
class dvdListType:public unorderedLinkedList<dvdType>
{
public:
bool dvdSearch(string title) const;
//Function to search the list to see whether a
//particular title, specified by the parameter title,
//is in the store.
//Postcondition: Returns true if the title is found,
// and false otherwise.
bool isDVDAvailable(string title) const;
//Function to determine whether a copy of a particular
//DVD is in the store.
//Postcondition: Returns true if at least one copy of the
// DVD specified by title is in the store,
// and false otherwise.
void dvdCheckOut(string title);
//Function to check out a DVD, that is, rent a DVD.
//Postcondition: copiesInStock is decremented by one.
void dvdCheckIn(string title);
//Function to check in a DVD returned by a customer.
//Postcondition: copiesInStock is incremented by one.
bool dvdCheckTitle(string title) const;
//Function to determine whether a particular DVD is in
//the store.
//Postcondition: Returns true if the DVD’s title is
// the same as title, and false otherwise.
void dvdUpdateInStock(string title, int num);
//Function to update the number of copies of a DVD
//by adding the value of the parameter num. The
//parameter title specifies the name of the DVD for
//which the number of copies is to be updated.
//Postcondition: copiesInStock = copiesInStock + num;
void dvdSetCopiesInStock(string title, int num);
//Function to reset the number of copies of a DVD.
//The parameter title specifies the name of the DVD
//for which the number of copies is to be reset, and the
//parameter num specifies the number of copies.
//Postcondition: copiesInStock = num;
void dvdPrintTitle() const;
//Function to print the titles of all the DVD in
//the store.
private:
void searchDVDList(string title, bool& found,
nodeType<dvdType>* &current) const;
//This function searches the DVD list for a
//particular DVD, specified by the parameter title.
//Postcondition: If the DVD is found, the parameter
// found is set to true, otherwise it is set
// to false. The parameter current points
// to the node containing the DVD.
};


#include <iostream>
#include <fstream>
#include <string>
#include "dvdType.h"
#include "dvdListType.h"
using namespace std;
void createDVDList(ifstream& infile,
dvdListType& dvdList);
void displayMenu();
int main()
{
dvdListType dvdList;
int choice;
char ch;
string title;
ifstream infile;
//open the input file
infile.open("dvdDat.txt");
if (!infile)
{
cout << "The input file does not exist. "
<< "The program terminates!!!" << endl;
return 1;
}
//create the DVD list
createDVDList(infile, dvdList);
infile.close();
//show the menu
displayMenu();
cout << "Enter your choice: ";
cin >> choice; //get the request
cin.get(ch);
cout << endl;
while (choice != 9)
{
switch (choice)
{
case 1:
cout << "Enter the title: ";
getline(cin, title);
cout << endl;
if (dvdList.dvdSearch(title))
cout << "The store carries " << title
<< endl;
else
cout << "The store does not carry "
<< title << endl;
break;
case 2:
cout << "Enter the title: ";
getline(cin, title);
cout << endl;
if (dvdList.dvdSearch(title))
{
if (dvdList.isDVDAvailable(title))
{
dvdList.dvdCheckOut(title);
cout << "Enjoy your movie: "
<< title << endl;
}
else
cout << "Currently " << title
<< " is out of stock." << endl;
}
else
cout << "The store does not carry "
<< title << endl;
break;
case 3:
cout << "Enter the title: ";
getline(cin, title);
cout << endl;
if (dvdList.dvdSearch(title))
{
dvdList.dvdCheckIn(title);
cout << "Thanks for returning "
<< title << endl;
}
else
cout << "The store does not carry "
<< title << endl;
break;
case 4:
cout << "Enter the title: ";
getline(cin, title);
cout << endl;
if (dvdList.dvdSearch(title))
{
if (dvdList.isDVDAvailable(title))
cout << title << " is currently in "
<< "stock." << endl;
else
cout << title << " is currently out "
<< "of stock." << endl;
}
else
cout << "The store does not carry "
<< title << endl;
break;
case 5:
dvdList.dvdPrintTitle();
break;
case 6:
dvdList.print();
break;
default:
cout << "Invalid selection." << endl;
}//end switch
displayMenu(); //display menu
cout << "Enter your choice: ";
cin >> choice; //get the next request
cin.get(ch);
cout << endl;
}//end while
return 0;
}
void createDVDList(ifstream& infile,
dvdListType& dvdList)
{
string title;
string star1;
string star2;
string producer;
string director;
string productionCo;
char ch;
int inStock;
dvdType newDVD;
getline(infile, title);
while (infile)
{
getline(infile, star1);
getline(infile, star2);
getline(infile, producer);
getline(infile, director);
getline(infile, productionCo);
infile >> inStock;
infile.get(ch);
newDVD.setDVDInfo(title, star1, star2, producer,
director, productionCo, inStock);
dvdList.insertFirst(newDVD);
getline(infile, title);
}//end while
}//end createDVDList
void displayMenu()
{
cout << "Select one of the following:" << endl;
cout << "1: To check whether the store carries a "<< "particular DVD." << endl;
cout << "2: To check out a DVD." << endl;
cout << "3: To check in a DVD." << endl;
cout << "4: To check whether a particular DVD is "<< "in stock." << endl;
cout << "5: To print only the titles of all the DVDs."<< endl;
cout << "6: To print a list of all the DVDs." << endl;
cout << "9: To exit" << endl;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote