Question: Question is about Video Store Program from Data Structures Using c++ by D.S. Malik. In the Video Store Program, videoListType uses the help of unorderedLinkedList
Question is about Video Store Program from Data Structures Using c++ by D.S. Malik.
In the Video Store Program,
videoListType uses the help of unorderedLinkedList . I need to implement it with the help of STL library and update the given member functions for the operations such as check video availability, check-in and check-out of videos, search and other member functions accordingly.
Given files:
videoListType.h
#include
#include "unorderedLinkedList.h"
#include "videoType.h"
using namespace std;
class videoListType:public unorderedLinkedList
{
public:
bool videoSearch(string title) const;
//Function to search the list to see whether a particular title is in the store.
bool isVideoAvailable(string title) const;
//Function to determine whether a copy of a particular video is in the store.
void videoCheckOut(string title);
//Function to check out a video, that is, rent a video.copiesInStock is decremented by one.
void videoCheckIn(string title);
//Function to check in a video returned by a customer.copiesInStock is incremented by one.
bool videoCheckTitle(string title) const;
//Function to determine whether a particular video is in the store.
void videoUpdateInStock(string title, int num);
//Function to update the number of copies of a video. copiesInStock = copiesInStock + num;
void videoSetCopiesInStock(string title, int num);
//Function to reset the number of copies of a video. copiesInStock = num;
void videoPrintTitle() const;
//Function to print the titles of all the videos in the store.
private:
void searchVideoList(string title, bool& found, nodeType
//This function searches the video list for a particular video, specified by the parameter title.
//Postcondition: If the video is found, the parameter found is set to true, otherwise it is set to false.
//The parameter current points to the node containing the video.
};
videoListTypeImp.cpp
#include
#include
#include "videoListType.h"
using namespace std;
/*
Change the necessary implementations via the usage of STL instead of unordered Linked List here
*/
/*Code snippets for reference are given below*/
void videoListType::searchVideoList(string title, bool& found,
nodeType
{
found = false; //set found to false
current = first; //set current to point to the first node
//in the list
while (current != NULL && !found) //search the list
if (current->info.checkTitle(title)) //the item is found
found = true;
else
current = current->link; //advance current to
//the next node
}//end searchVideoList
bool videoListType::isVideoAvailable(string title) const
{
bool found;
nodeType
searchVideoList(title, found, location);
if (found)
found = (location->info.getNoOfCopiesInStock() > 0);
else
found = false;
return found;
}
void videoListType::videoCheckIn(string title)
{
bool found = false;
nodeType
searchVideoList(title, found, location); //search the list
if (found)
location->info.checkIn();
else
cout << "The store does not carry " << title
<< endl;
}
void videoListType::videoCheckOut(string title)
{
bool found = false;
nodeType
searchVideoList(title, found, location); //search the list
if (found)
location->info.checkOut();
else
cout << "The store does not carry " << title
<< endl;
}
bool videoListType::videoCheckTitle(string title) const
{
bool found = false;
nodeType
searchVideoList(title, found, location); //search the list
return found;
}
void videoListType::videoUpdateInStock(string title, int num)
{
bool found = false;
nodeType
searchVideoList(title, found, location); //search the list
if (found)
location->info.updateInStock(num);
else
cout << "The store does not carry " << title
<< endl;
}
void videoListType::videoSetCopiesInStock(string title, int num)
{
bool found = false;
nodeType
searchVideoList(title, found, location);
if (found)
location->info.setCopiesInStock(num);
else
cout << "The store does not carry " << title
<< endl;
}
bool videoListType::videoSearch(string title) const
{
bool found = false;
nodeType
searchVideoList(title, found, location);
return found;
}
void videoListType::videoPrintTitle() const
{
nodeType
current = first;
while (current != NULL)
{
current->info.printTitle();
current = current->link;
}
}
//template void videoListType::searchVideoList//
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
