📄 guest.h
字号:
#ifndef GUEST_H
#define GUEST_H
#include"union.h"
//*****************************************************************************
//* Sell(出售图书)函数 *
//*****************************************************************************
void Sell(float percent)
{
struct sellbook{
int count;
int quantity;
}n[101]; //购书记录结构体
int choice,data,book,nmax=1;
char select,title[40];
loope:
system("cls");
cout<<endl<<endl<<endl<<endl<<endl;
if(percent<1)
cout<<" 顾客朋友您好,本书店今日全部图书"<<percent<<"折出售,欢迎您选购!"<<endl<<endl;
else
cout<<" 顾客朋友您好,欢迎您来本店选购图书!"<<endl<<endl;
cout<<" 您想通过哪种索引来选购?(1.书号 2.书名)"<<endl;
do{
cout<<endl<<" 请在1和2中选择:";
cin>>choice;
cin.ignore();
}while(choice!=1 && choice!=2);
if(choice==1)
{
cout<<endl<<" 请输入您要购买图书的书号:";
cin>>data;
cout<<endl;
Numsort(1,max-1);
book=Search(data,1,max-1); //完成按书号查找
}
else
{
cout<<endl<<" 请输入您要购买图书的书名:";
cin>>title;
cout<<endl;
Titsort(1,max-1);
book=Tisearch(title,1,max-1); //完成按书名查找
}
if(!book)
{
cout<<endl<<" 对不起,本书店没有您所需的图书,请谅解!"<<endl;
do
{
cout<<endl<<" 需要购买其他图书吗?(Y/N)"<<endl;
cin>>select;
select=toupper(select);
cin.ignore();
}while(select!='Y' && select!='N');
if(select=='Y') goto loope;
}
else
{
system("cls");
cout<<endl<<endl<<endl<<endl<<endl;
cout<<" 已找到您所需的图书"<<endl<<endl;
cout<<" 书号:"<<Book[book].getNum()<<endl;
cout<<" 书名:"<<Book[book].getTitle()<<endl;
cout<<" 作者:"<<Book[book].getAuthor()<<endl;
cout<<" 出版社:"<<Book[book].getPub()<<endl;
cout<<" 库存量:"<<Book[book].getQty()<<"本"<<endl;
cout<<" 原售价:"<<Book[book].getCost()<<"元"<<endl;
cout<<" 现价:"<<percent*Book[book].getCost()<<"元"<<endl;
if(Book[book].getQty())
{
n[nmax].count=book;
cout<<endl<<" 您需要购买多少本?";
cin>>data;
Book[book].setQty(Book[book].getQty()-data); //库存量相应减少
if(data==0) cout<<endl<<endl;
else
{
n[nmax++].quantity=data;
cout<<endl<<" 操作成功,谢谢!"<<endl<<endl;
}
}
else
cout<<endl<<" 很抱歉,此书已经没有库存,请您见谅!"<<endl<<endl;
do
{
cout<<" 您要选购其他图书吗?(Y/N)"<<endl;
cin>>select;
select=toupper(select);
cin.ignore();
}while(select!='Y' && select!='N');
if(select=='Y') goto loope; //返回路径点选购其他图书
}
if(nmax>1) //若顾客已选购了图书
{
system("cls");
cout<<endl<<endl;
cout<<" 您选购的图书如下 "<<endl;
cout<<" ********************************************************************"<<endl;
cout<<" * 书号 书名 类型 数量 总价 *"<<endl;
for(int i=1;i<nmax;i++)
{
cout<<" * "<<i<<". "<<setw(02)<<Book[n[i].count].getNum();
cout<<setw(25)<<Book[n[i].count].getTitle();
switch(Book[n[i].count].getKind())
{
case 1: cout<<setw(11)<<"教育"; break;
case 2: cout<<setw(11)<<"军事"; break;
case 3: cout<<setw(11)<<"历史"; break;
case 4: cout<<setw(11)<<"文学"; break;
case 5: cout<<setw(11)<<"科技"; break;
case 6: cout<<setw(11)<<"娱乐"; break;
}
cout<<setw(8)<<n[i].quantity;
cout<<setw(9)<<percent*Book[n[i].count].getCost()*n[i].quantity<<" *"<<endl;
} //生成顾客购书列表
cout<<" ********************************************************************"<<endl;
do
{
cout<<" 是否确认?(Y/N)"<<endl;
cin>>select;
select=toupper(select);
cin.ignore();
}while(select!='Y' && select!='N');
if(select=='N')
{
for(i=0;i<nmax;i++)
Book[n[i].count].setQty(Book[n[i].count].getQty()+n[i].quantity);
//还原库存量
nmax=1;
goto loope; //返回路径点重新选购图书
}
else
cout<<" 购买已完成,谢谢!"<<endl;
}
}
//*****************************************************************************
//* Rules(管理规定)函数 *
//*****************************************************************************
void Rules(void)
{
system("cls");
cout<<endl<<" 书店管理规定 "<<endl;
cout<<endl<<" 1. 请保持店内安静秩序,文明礼貌,轻拿轻放,勿大声喧哗。 "<<endl;
cout<<endl<<" 2. 注意着装整洁、大方,衣冠不整者谢绝入内。 "<<endl;
cout<<endl<<" 3. 店内严禁吸烟,严禁携带危险品或其他管制物品入内。 "<<endl;
cout<<endl<<" 4. 请保持店内清洁,禁止随地吐痰,乱扔果皮、纸屑等杂物。 "<<endl;
cout<<endl<<" 5. 爱护图书、报刊、文献资料、设施,严禁随意涂抹、刻画、损坏书刊 "<<endl;
cout<<endl<<" 和公物,违者按章赔偿。 "<<endl;
cout<<endl<<" 6. 本系统包含权限设置,顾客不可操作超越权限的功能,请注意。 "<<endl;
cout<<endl<<" 7. 如造成图书损坏、污染、遗失等,顾客须照章赔偿。 "<<endl;
cout<<endl<<" 8. 欢迎您在本店选购图书,谢谢您的配合。 "<<endl;
cout<<endl<<" 按回车键返回 "<<endl;
cin.get();
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -