Please be original and no copy and pasting. Write the definitions of the functio
ID: 3662611 • Letter: P
Question
Please be original and no copy and pasting.
Write the definitions of the functions of the class videoBinaryTree not given in the Programming Example Video Store. Also write a program to test the video store program. 13. (Video Store Program) In Programming Exercise 14 in Chapter 5, you were asked to design and implement a class to maintain customer data in a linked list. Because the search on a linked list is sequential and, therefore, can be time consuming, design and implement the class customerBTreeType so that this customer data can be stored in a binary search tree. The class customerBTreeType must be derived from the class bSearchTreeType as designed in this chapter. 14. (Video Store Program) Using classes to implement the video data, video list data, customer data, and customer list data, as designed in this chapter and in Programming Exercises 12 and 13, design and complete the program to put the video store into operation.
Here is the code so far
#include <iostream>
#include <string>
#include "videoBinaryTree.h"
using namespace std;
bool videoBinaryTree::isVideoAvailable(string title)
{
cout << "See Programming Exercise 12." << endl;
return false;
}
void videoBinaryTree::videoCheckIn(string title)
{
cout << "See Programming Exercise 12." << endl;
}
void videoBinaryTree::videoCheckOut(string title)
{
cout << "See Programming Exercise 12." << endl;
}
bool videoBinaryTree::videoCheckTitle(string title)
{
cout << "See Programming Exercise 12." << endl;
return false;
}
void videoBinaryTree::videoUpdateInStock(string title, int num)
{
cout << "See Programming Exercise 12." << endl;
}
void videoBinaryTree::videoSetCopiesInStock(string title,
int num)
{
cout << "See Programming Exercise 12." << endl;
}
bool videoBinaryTree::videoSearch(string title)
{
cout << "See Programming Exercise 12." << endl;
return false;
}
void videoBinaryTree::searchVideoList(string title, bool& found,
binaryTreeNode<videoType>* ¤t)
{
found = false;
videoType temp;
temp.setVideoInfo(title, "", "", "", "", "", 0);
if (root == NULL) //the tree is empty
cout << "Cannot search an empty list. " << endl;
else
{
current = root; //set current point to the root node
//of the binary tree
found = false; //set found to false
while (!found && current != NULL) //search the tree
if (current->info == temp) //the item is found
found = true;
else if(current->info > temp)
current = current->llink;
else
current = current->rlink;
} //end else
}
void videoBinaryTree::videoPrintTitle()
{
inorderTitle(root);
}
void videoBinaryTree::inorderTitle(binaryTreeNode<videoType> *p)
{
if (p != NULL)
{
inorderTitle(p->llink);
p->info.printTitle();
inorderTitle(p->rlink);
}
}
#include <iostream>
#include <string>
#include "videoType.h"
using namespace std;
void videoType::setVideoInfo(string title, string star1,
string star2, string producer,
string director,
string productionCo,
int setInStock)
{
videoTitle = title;
movieStar1 = star1;
movieStar2 = star2;
movieProducer = producer;
movieDirector = director;
movieProductionCo = productionCo;
copiesInStock = setInStock;
}
void videoType::checkIn()
{
copiesInStock++;
}
void videoType::checkOut()
{
if(getNoOfCopiesInStock() > 0)
copiesInStock--;
else
cout<<"Currently out of Stock"<<endl;
}
int videoType::getNoOfCopiesInStock() const
{
return copiesInStock;
}
void videoType::printTitle() const
{
cout<<"Video Title: "<<videoTitle<<endl;
}
void videoType::printInfo() const
{
cout<<"Video Title: "<<videoTitle<<endl;
cout<<"Stars: "<<movieStar1<<" and "<<movieStar2<<endl;
cout<<"Producer: "<<movieProducer<<endl;
cout<<"Director: "<<movieDirector<<endl;
cout<<"Production Company: "<<movieProductionCo<<endl;
cout<<"Copies in stock: "<<copiesInStock<<endl;
}
bool videoType::checkTitle(string title)
{
return(videoTitle == title);
}
void videoType::updateInStock(int num)
{
copiesInStock += num;
}
void videoType::setCopiesInStock(int num)
{
copiesInStock = num;
}
string videoType::getTitle()
{
return videoTitle;
}
videoType::videoType(string title, string star1,
string star2, string producer,
string director, string productionCo,
int setInStock)
{
videoTitle = title;
movieStar1 = star1;
movieStar2 = star2;
movieProducer = producer;
movieDirector = director;
movieProductionCo = productionCo;
copiesInStock = setInStock;
}
bool videoType::operator==(const videoType& right) const
{
return (videoTitle == right.videoTitle);
}
bool videoType::operator!=(const videoType& right) const
{
return (videoTitle != right.videoTitle);
}
bool videoType::operator<(const videoType& right) const
{
return (videoTitle < right.videoTitle);
}
bool videoType::operator<=(const videoType& right) const
{
return (videoTitle <= right.videoTitle);
}
bool videoType::operator>(const videoType& right) const
{
return (videoTitle > right.videoTitle);
}
bool videoType::operator>=(const videoType& right) const
{
return (videoTitle >= right.videoTitle);
}
ostream& operator<<(ostream& os, const videoType &video)
{
os<<endl;
os<<"Video Title: "<<video.videoTitle<<endl;
os<<"Stars: "<<video.movieStar1<<" and "
<<video.movieStar2<<endl;
os<<"Producer: "<<video.movieProducer<<endl;
os<<"Director: "<<video.movieDirector<<endl;
os<<"Production Company: "<<video.movieProductionCo<<endl;
os<<"Copies in stock: "<<video.copiesInStock<<endl;
os<<"_____________________________________"<<endl;
return os;
}
Test
#include <iostream>
#include <string>
#include "videoType.h"
using namespace std;
void videoType::setVideoInfo(string title, string star1,
string star2, string producer,
string director,
string productionCo,
int setInStock)
{
videoTitle = title;
movieStar1 = star1;
movieStar2 = star2;
movieProducer = producer;
movieDirector = director;
movieProductionCo = productionCo;
copiesInStock = setInStock;
}
void videoType::checkIn()
{
copiesInStock++;
}
void videoType::checkOut()
{
if(getNoOfCopiesInStock() > 0)
copiesInStock--;
else
cout<<"Currently out of Stock"<<endl;
}
int videoType::getNoOfCopiesInStock() const
{
return copiesInStock;
}
void videoType::printTitle() const
{
cout<<"Video Title: "<<videoTitle<<endl;
}
void videoType::printInfo() const
{
cout<<"Video Title: "<<videoTitle<<endl;
cout<<"Stars: "<<movieStar1<<" and "<<movieStar2<<endl;
cout<<"Producer: "<<movieProducer<<endl;
cout<<"Director: "<<movieDirector<<endl;
cout<<"Production Company: "<<movieProductionCo<<endl;
cout<<"Copies in stock: "<<copiesInStock<<endl;
}
bool videoType::checkTitle(string title)
{
return(videoTitle == title);
}
void videoType::updateInStock(int num)
{
copiesInStock += num;
}
void videoType::setCopiesInStock(int num)
{
copiesInStock = num;
}
string videoType::getTitle()
{
return videoTitle;
}
videoType::videoType(string title, string star1,
string star2, string producer,
string director, string productionCo,
int setInStock)
{
videoTitle = title;
movieStar1 = star1;
movieStar2 = star2;
movieProducer = producer;
movieDirector = director;
movieProductionCo = productionCo;
copiesInStock = setInStock;
}
bool videoType::operator==(const videoType& right) const
{
return (videoTitle == right.videoTitle);
}
bool videoType::operator!=(const videoType& right) const
{
return (videoTitle != right.videoTitle);
}
bool videoType::operator<(const videoType& right) const
{
return (videoTitle < right.videoTitle);
}
bool videoType::operator<=(const videoType& right) const
{
return (videoTitle <= right.videoTitle);
}
bool videoType::operator>(const videoType& right) const
{
return (videoTitle > right.videoTitle);
}
bool videoType::operator>=(const videoType& right) const
{
return (videoTitle >= right.videoTitle);
}
ostream& operator<<(ostream& os, const videoType &video)
{
os<<endl;
os<<"Video Title: "<<video.videoTitle<<endl;
os<<"Stars: "<<video.movieStar1<<" and "
<<video.movieStar2<<endl;
os<<"Producer: "<<video.movieProducer<<endl;
os<<"Director: "<<video.movieDirector<<endl;
os<<"Production Company: "<<video.movieProductionCo<<endl;
os<<"Copies in stock: "<<video.copiesInStock<<endl;
os<<"_____________________________________"<<endl;
return os;
}
Explanation / Answer
// Impementation of Functions of class VideoBinary Tree .
#include <iostream>
#include <fstream>
#include <string>
#include "binarySearchTree.h"
#include "videoType.h"
#include "videoBinaryTree.h"
using namespace std;
void createVL(ifstream& readfile,
videoBinaryTree& vL);
void dispMenu();
int main()
{
videoBinaryTree vL;
int ch;
string name;
ifstream readfile;
readfile.open("vid.txt");
if (!readfile)
{
cout << "File you asked for does not exist. "
<< "Reached End of Program!!"<< endl;
return 1;
}
createVL(readfile, vL);
readfile.close();
dispMenu(); //show the menu
cout << "Enter your choice: ";
cin >> ch; //get the request
cin.ignore(55, ' '); //ignore the remaining
//characters in the line
cout << endl;
while (ch != 9)
{
switch (ch)
{
case 1:
cout << "Enter the name of Video: ";
getline(cin, name);
cout << endl;
if (vL.videoSearch(name))
cout << "Video store is having " << name << endl;
else
cout << "Video store does not contain " << name
<< endl;
break;
case 2:
cout << "Enter the name of video: ";
getline(cin, name);
cout << endl;
if (vL.videoSearch(name))
{
if (videoList.isVideoAvailable(name))
{
videoList.videoCheckOut(name);
cout << "Have Fun with your video " << name
<< endl;
}
else
cout << "For now " << name
<< " is not available ." << endl;
}
else
cout << "This video Store does not contain " << name
<< endl;
break;
case 3:
cout << "Enter the name of video: ";
getline(cin, name);
cout << endl;
if (vL.videoSearch(name))
{
videoList.videoCheckIn(name);
cout << "Thank you for " << name
<< endl;
}
else
cout << "The video store does not contain " << name
<< endl;
break;
case 4:
cout << "Enter the name of the video: ";
getline(cin, name);
cout << endl;
if (vL.videoSearch(name))
{
if (vL.isVideoAvailable(name))
cout << name << " is currently "
<< "available." << endl;
else
cout << name << " is currently not "
<< "available." << endl;
}
else
cout << "The store does not contain " << name
<< endl;
break;
case 5:
vL.videoPrintTitle();
break;
case 6:
vL.inorderTraversal();
break;
default: cout << "You have selected wrong choice." << endl;
}//end switch
dispmenu(); //display the menu
cout << "Enter your ch: ";
cin >> ch; //get the next request
cin.ignore(100, ' '); //ignore the remaining
//characters in the line
cout << endl;
}//end while
return 0;
}
void createVL(ifstream& readfile,
videoBinaryTree& videoList)
{
string name;
string str1;
string str2;
string prod; //Producer
string dir; //Director
string productionCo;
int stk; // in stock no.
videoType vid;
getline(readfile, name);
while (readfile)
{
getline(readfile, str1);
getline(readfile, str2);
getline(readfile, prod);
getline(readfile, dir);
getline(readfile, productionCo);
readfile >> stk;
readfile.ignore(55, ' ');
vid.setVideoInfo(name, str1, str2, prod,
dir, productionCo, stk);
videoList.insert(vid);
getline(readfile, name);
}//end while
}//end createVL
void dispmenu()
{
cout << "Welcome to the new Video Store" << endl;
cout << "You are looking for." << endl;
cout << "Enter your choice: How may I help you?" << endl;
cout << "1: To check whether the store is having"
<< "desired video." << endl;
cout << "2: To check out a video." << endl;
cout << "3: To check in a video." << endl;
cout << "4: To check whether a particular video is "
<< "in stock." << endl;
cout << "5: To print the names of all the videos that are there in our stock."
<< endl;
cout << "6: To print a list of all the videos." << endl;
cout << "9: To say Bye!!!" << endl;
}