C++宠物商店管理系统

这个C++程序实现了宠物商店管理系统,包括宠物的增删查改、交易记录的录入和查询、顾客信息的管理等功能。用户可以进行新添加宠物、查找宠物、删除宠物、显示所有宠物、修改宠物信息等操作,并提供了相应的菜单界面。
摘要由CSDN通过智能技术生成

int Pet::xianshi()

{
int menu;
cout<<“宠物店管理系统**”<<endl;
cout <<endl;
cout<< endl<<endl;
cout<<" ╭╧╮ ╭╧╮ ╭╧╮ ╭╧╮ ╭╧╮ ╭╧╮ ╭╧╮ ╭╧╮╭╧╮╭╧╮╭╧╮ “<<endl;
cout<<” │ │ “<<endl;
cout<<” │ ★★★★★ 欢迎您的使用 ★★★★★ │ “<<endl;
cout<<” │ ☆ (__) ☆ │ “<<endl;
cout<<” │ │ “<<endl;
cout<<” │ 1.新添加宠物 2.查找宠物 3.删除宠物 │ “<<endl;
cout<<” │ │ “<<endl;
cout<<” │ 7. 结束运行 │ “<<endl;
cout<<” │ │ “<<endl;
cout<<” │ 4.显示所有 5.修改宠物 6.返回主菜单 │ “<<endl;
cout<<” ╰---------------------------------------------------------------------╯ "<<endl;
cout<<endl<<“请选择相应操作菜单项:”<<endl;
cin>>menu;
while(menu<1||menu>7)
{
cout<<“请选择正确的菜单选项:”<<endl;
cin.clear(); /清除输入/
cin>>menu;
}

return menu;
system(“cls”);
}

2)录入函数 AllPrint():输入ID到数量的宠物信息;
//成员函数的实现
void Pet::AddPet()//增加宠物输入文本中
{

do{
	cout<<" *****************************增加新的宠物******************************* "<<endl;
	cout<<"输入宠物编号ID:";
	cin>>ID;
	cout<<endl;
	if(Inquire(ID))		
	{
		cout<<"输入宠物名:";
		cin>>petname;
		fflush(stdin);
		cout<<"体重:";
		cin>>weight;
		fflush(stdin);
		cout<<"年龄:";
		cin>>age;
		fflush(stdin);
		cout<<"类别:";
		cin>>category;
		fflush(stdin);
		cout<<"性格:";
		cin>>character;
		fflush(stdin);
		cout<<"价格:";
		cin>>price;
		fflush(stdin);
		cout<<"数量:";
		cin>>count;
		cout<<"\t\tID\t"<<ID<<endl<<"\t\t宠物名\t"<<petname<<endl<<"\t\t体重\t"<<weight<<endl<<"\t\t年龄\t"<<age<<endl<<"\t\t类别\t"<<category<<endl<<"\t\t性格\t"<<character<<endl
		<<"\t\t宠物价格\t"<<price<<endl<<"\t\t宠物数量\t"<<count<<endl;
		fflush(stdin);
		
			}character 
	else
	{
		cout<<"输入的ID以存在,请重新输入!!"<<endl;
	}

}while(!(Inquire(ID)));
save();
cout<<endl<<"**********************信息已保存 !!!******************"<<endl;
system("pause");
system("cls");

}

3)查询函数 search() :查询指定宠物的信息;
void Pet::search()//查找宠物信息
{
ifstream inData(“pet”,ios::in);

if(!inData)                                
{
 cout<<endl<<"对不起!!!!文件找不到!!!!"<<endl;
 system("pause");
 return;
}
string sign;
cout<<endl<<"输入你想查找的宠物的编号或名称: ";
cin>>sign;            
bool flag=true;    
string  str;
while(inData>>ID>>petname)
{
	  getline(inData, str);                          /*字符str用来接受除 与输入编号或影片名称相同之外的其他信息*/       
    if((ID==sign)||(petname==sign))
    {
        cout<<endl<<"你要查找的宠物信息是: "<<endl<<endl;  
		cout<<setiosflags(ios::left)<<setw(8)<<"ID"<<setw(8)<<"宠物名"<<setw(8)<<"体重"<<setw(8)<<"年龄"<<setw(8)<<"类别"<<setw(8)<<"性格"<<setw(8)<<"单价"<<setw(8)<<"数量"<<endl;
        cout<<setiosflags(ios::left)<<setw(8)<<ID<<petname<<str<<endl;/*输出所要查找的人的信息*/
        flag=false;

       continue;
    }
}
if(flag)
{
cout<<"没找到你的宠物!!!";

}
system("pause");
system("cls");

}

4)删除函数 Del() :删除宠物信息;
void Pet::Del()//删除宠物信息
{
ifstream inData(“pet”,ios::in);
ofstream outData(“pet1”,ios::out);
if(!inData)
{
cout<<“对不起! 打不开此文件。”;
system(“pause”);
return;

}
string str,del;
cout<<"请输入要删除的宠物ID或名字:"<<endl;
cin>>str;	
bool flag=true;
while(inData>>ID>>petname)
{
	getline(inData,del);
	if(ID==str||petname==str)
	{	
		cout<<setiosflags(ios::left)<<setw(8)<<"您所要删除的宠物:"<<endl;
		cout<<setiosflags(ios::left)<<
  • 7
    点赞
  • 45
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值