?? videobinarytreeimp.cpp
字號(hào):
#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);
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -