📄 videobinarytreeimp.cpp
字号:
#include <iostream>
#include <string>
#include "videoBinaryTree.h"
using namespace std;
bool videoBinaryTree::isVideoAvailable(string title)
{
bool found;
nodeType<videoType> *location;
searchVideoList(title, found, location);
if (found)
found = (location->info.getNoOfCopiesInStock() > 0);
else
found = false;
return found;
}
void videoBinaryTree::videoCheckIn(string title)
{
bool found = false;
nodeType<videoType> *location;
searchVideoList(title, found, location);
if (found)
location->info.checkIn();
else
cout << "The store does not carry " << title
<< endl;
}
void videoBinaryTree::videoCheckOut(string title)
{
bool found = false;
nodeType<videoType> *location;
searchVideoList(title, found, location);
if (found)
location->info.checkOut();
else
cout << "The store does not carry " << title
<< endl;
}
bool videoBinaryTree::videoCheckTitle(string title) const
{
bool found = false;
nodeType<videoType> *location;
searchVideoList(title, found, location);
return found;
}
void videoBinaryTree::videoUpdateInStock(string title, int num)
{
bool found = false;
nodeType<videoType> *location;
searchVideoList(title, found, location);
if (found)
location->info.updateInStock(num);
else
cout << "The store does not carry " << title
<< endl;
}
void videoBinaryTree::videoSetCopiesInStock(string title,
int num)
{
bool found = false;
nodeType<videoType> *location;
searchVideoList(title, found, location);
if (found)
location->info.setCopiesInStock(num);
else
cout << "The store does not carry " << title
<< endl;
}
bool videoBinaryTree::videoSearch(string title)
{
bool found = false;
nodeType<videoType> *location;
searchVideoList(title, found, location);
return found;
}
void videoBinaryTree::searchVideoList(string title,
bool& found,
nodeType<videoType>* ¤t) const
{
found = false;
videoType temp;
temp.setVideoInfo(title, "", "", "", "", "", 0);
if (root == NULL) //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 (current != NULL && !found) //search the tree
if (current->info == temp) //item is found
found = true;
else if (current->info > temp)
current = current->lLink;
else
current = current->rLink;
} //end else
} //end searchVideoList
void videoBinaryTree::videoPrintTitle() const
{
inorderTitle(root);
}
void videoBinaryTree::inorderTitle
(nodeType<videoType> *p) const
{
if (p != NULL)
{
inorderTitle(p->lLink);
p->info.printTitle();
inorderTitle(p->rLink);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -