📄 videolisttype.cpp
字号:
#include "videoListType.h"
#include <iostream.h>
bool videoListType::isVideoAvailable(newString title) //检查某张影碟数量是否>1
{
bool found;
nodeType<videoType>* location;
searchVideoList(title,found,location); //注意searchVideoList中的
//found 要用引用才能改变值
if(found)
found = (location->info.getNoOfCopiesInStock() > 0);
else
found = false;
return found;
}
void videoListType::videoCheckIn(newString title) //返还一张碟
{
bool found = false;
nodeType<videoType>* location;
searchVideoList(title,found,location);
if(found)
location->info.checkIn(); //注意,用了videoType中的checkIn
else
cout<<"Video not in stock 此碟不是本商店的"<<endl;
}
void videoListType::videoCheckOut(newString title) //出租一张碟
{
bool found = false;
nodeType<videoType>* location;
searchVideoList(title,found,location);
if(found)
location->info.checkOut(); //注意用了videoType中的checkOut
else
cout<<"Video not in stock 商店没有此碟"<<endl;
}
bool videoListType::videoCheckTitle(newString title) //查找库中有没有此碟
{
bool found = false;
nodeType<videoType>* location;
searchVideoList(title,found,location);
return found;
}
void videoListType::videoUpdateInStock(newString title,int num)//增加某张碟的数量
{
bool found = false;
nodeType<videoType>* location;
searchVideoList(title,found,location);
if(found)
location->info.updateInStock(num); //更新
else
cout<<"Video not in stock库中并没有此碟"<<endl;
}
void videoListType::videoSetCopiesInStock(newString title,int num)//设置某张碟的数量
{
bool found = false;
nodeType<videoType>* location;
searchVideoList(title,found,location);
if(found)
location->info.setCopiesInStock(num); //设置
else
cout<<"Video not in stock"<<endl;
}
bool videoListType::videoSearch(newString title) //查看库中是否有此碟
{
bool found = false;
nodeType<videoType>* location;
searchVideoList(title,found,location);
return found;
}
void videoListType::videoPrintTitle() //打印所有碟的名字
{
nodeType<videoType>* current;
current = first;
while(current != NULL)
{
current->info.printTitle();
current = current->link;
}
}
void videoListType::videoPrintInfo(newString title) //自己增加的函数
{
bool found = false;
nodeType<videoType>* location;
searchVideoList(title,found,location);
if(found)
location->info.printInfo();
}
void videoListType::searchVideoList(newString title,bool& found,
nodeType<videoType>* ¤t)
{
found = false;
if(first == NULL)
cout<<"Cannot search an empty list."<<endl;
else
{
current = first;
while(!found && current !=NULL)
{
if(current->info.checkTitle(title))
found = true;
else
current = current->link;
}
}
}
void videoListType::insertVideo()
{/*custType customer;
newString acctno;
newString fname;
newString lname;
cout<<"请输入帐号:";
cin>>acctno;
while(seachAcctNo(acctno)) //用到了上面的seachAccNo函数!!!
{
cout<<"你所输入的帐号已经存在,请重新输入!";
cout<<"请输入帐号:";
cin>>acctno;
}
cout<<"请输入名字:";
cin>>fname;
cout<<"请输入姓氏:";
cin>>lname;
customer.setCustInfo(acctno,fname,lname," "," "," ");
insertFirst(customer);*/
videoType video;
newString title;
newString star1;
newString star2;
newString producer;
newString director;
newString productionCo;
int copiesinstock;
cout<<"请输入影碟名:";
cin>>title;
cout<<"请输入主演1:";
cin>>star1;
cout<<"请输入主演2:";
cin>>star2;
cout<<"请输入制片人:";
cin>>producer;
cout<<"请输入导演:";
cin>>director;
cout<<"请输入制片厂:";
cin>>productionCo;
cout<<"请输入库存量:";
cin>>copiesinstock;
video.setVideoInfo(title,star1,star2,producer,director,productionCo,copiesinstock);
insertFirst(video);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -