宠物店小型管理系统C++代码.docx
《宠物店小型管理系统C++代码.docx》由会员分享,可在线阅读,更多相关《宠物店小型管理系统C++代码.docx(59页珍藏版)》请在冰豆网上搜索。
宠物店小型管理系统C++代码
编写的宠物店管理系统的代码,要想运行成功要创建一个主函数文件,三个头文件,分别是pet,customer,saleItem.还要在你工程文件夹里创建几个txt文本就可以进行添加、删除、修改了。
分别为pet,pet1,customer1,customer,saleItem,saleItem1.注意不要加后缀名.txt..
源代码:
//主函数
#include
#include
#include"pet.h"
#include"customer.h"
#include"saleItem.h"
usingnamespacestd;
intmain()
{
intch;
intn=1,m=1;//控制输入密码次数;
staticchardeng[5]="yeke",mi[5]="1234";
charlu[5],ma[5];
Peta;/*对象a*/
Customerb;/*对象b*/
SaleItemc;
while
(1)
{
loop:
{
cout<<"**********************宠物店管理系统*************************"<cout<cout<cout<<"╭╧╮╭╧╮╭╧╮╭╧╮╭╧╮╭╧╮╭╧╮╭╧╮╭╧╮╭╧╮╭╧╮"<cout<<"││"<cout<<"│★★★★★欢迎进入管理系统★★★★★│"<cout<<"│☆☆宠物店超市☆☆│"<cout<<"│1、登陆宠物系统│"<cout<<"│2、客户系统│"<cout<<"│3、账单系统│"<cout<<"│4、退出│"<cout<<"╰---------------------------------------------------------------╯"<cout<<"请选择相应的功能编号:
";
}
cin>>ch;
if(ch<1||ch>4)
{
cout<<"请正确输入:
";
cin.clear();
cin>>ch;
}
system("cls");
switch(ch){
case1:
do{
a.denglupet();
cout<<"请输入密码第"<";
cin>>lu;
cout<cout<<"请输入账号:
";
cin>>ma;
if(n==3)
{
return0;
}
n++;m++;
}while(strcmp(lu,deng)!
=0||strcmp(ma,mi)!
=0);
system("cls");
while
(1)
{
do
{
switch(a.xianshi())
{
case1:
a.AddPet();break;
case2:
a.search();break;
case3:
a.Del();break;
case4:
a.AllPrint();break;
case5:
a.ChangePet();break;
case6:
gotoloop;
case7:
cout<<"成功退出系统!
"<return0;
}
}while
(1);
break;
}
break;
case2:
do{
switch(b.XianShi())
{
case1:
b.add();break;
case2:
b.del();break;
case3:
b.alter();break;
case4:
b.show();break;
case5:
gotoloop;
case6:
cout<<"成功推出系统!
"<return0;
}
}while
(1);
break;
case3:
do{
switch(c.menu())
{
case1:
c.Addsale();break;
case2:
c.delesale();break;
case3:
c.search();break;
case4:
c.AllPrint();break;
case5:
gotoloop;
case6:
cout<<"成功推出系统!
"<return0;
}
}while
(1);
case4:
cout<<"成功推出系统!
"<return0;
}
}
}
#include
#include
#include//表示引入头文件中声明的内容,在本文件中直接可以使用
#include//是包含I/O流控制头文件
#include
usingnamespacestd;
classCustomer{
private:
stringtelephone;
stringname;
public:
voidadd();/*增加顾客*/
intXianShi();/*显示菜单*/
voiddel();/*删除顾客*/
voidalter();/*修改顾客信息*/
voidsearch();/*查找顾客信息*/
voidsave();/*保存顾客信息*/
boolInquire(stringa);/*判断用户是否已注册*/
voidshow();//查询顾客为n的姓名是否存在回ture
};
//增加顾客
voidCustomer:
:
add()
{
do{
cout<<"*****************************注册新用户*******************************"<cout<<"输入新客户的姓名:
";
cin>>name;
cout<if(Inquire(name))//如果文件里没有返回true
{
cout<<"输入新客户的联系方式:
";
cin>>telephone;
cout<break;
}
else
{
cout<<"姓名已被人注册,请重新输入!
!
"<}
}while
(1);
save();
cout<system("pause");
system("cls");
}
voidCustomer:
:
del()//删除
{
ofstreamoutData("customer1",ios:
:
out);
ifstreaminData("customer",ios:
:
in);
if(!
inData)
{
cout<<"打不开文件!
!
"<system("pause");
return;
}
stringdel,name,str;
cout<<"输入你想删除的客户的名字:
";
cin>>del;
boolflag=true;
while(inData>>name>>telephone)
{
if(del==name)
{
cout<<"您所要删除的客户为:
"<cout<:
left)<"<cout<:
left)<flag=false;
continue;
}
outData<:
left)<}
outData.close();
inData.close();
if(flag)
{
cout<<"没有您要删除的客户的信息!
"<system("pause");
}
else
{
ofstreamoutData("customer",ios:
:
out);
ifstreaminData("customer1",ios:
:
in);
if(!
inData)
{
cout<<"对不起打不开文件!
"<system("pause");
return;
}
while(getline(inData,str))
{
outData<}
outData.close();
inData.close();
cout<<"客户已删除!
!
";
}
system("pause");
system("cls");
}
voidCustomer:
:
alter()//修改
{
ifstreaminData("customer",ios:
:
in);
ofstreamoutData("cu