C++《超市商品管理系统》课程设计报告
strcpy(temp->place,p1->place); temp->saleprice=p1->saleprice; temp->buyprice=p1->buyprice; temp->amount=p1->amount; temp->profit=p1->profit;
strcpy(temp->brand,p1->brand);
strcpy(p1->name,p2->name); p1->kind=p2->kind; strcpy(p1->Id,p2->Id);
strcpy(p1->place,p2->place); p1->saleprice=p2->saleprice; p1->buyprice=p2->buyprice; p1->amount=p2->amount; p1->profit=p2->profit;
strcpy(p1->brand,p2->brand);
strcpy(p2->name,temp->name); p2->kind=temp->kind; strcpy(p2->Id,temp->Id);
strcpy(p2->place,temp->place); p2->saleprice=temp->saleprice; p2->buyprice=temp->buyprice; p2->amount=temp->amount; p2->profit=temp->profit;
strcpy(p2->brand,temp->brand); }
int Goodsmessage::ListCount() //统计当前链表的记录总数,返回一个整数 {
if(! Head) return 0; int n=0;
for(Goods * p=Head->Next;p!=End;p=p->Next) {
n++; }
return n; }
36
C++《超市商品管理系统》课程设计报告
void Goodsmessage::Paixu() //﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌排序商品﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌ {
showMenu(4); int x; cin>>x; switch(x) {
case 1: {
system(\
cout <<\排序中...\ cout<<\
Goods *p=NULL,*p1=NULL,*k=NULL; int n=Goodsmessage::ListCount(); if(n<2) return;
for(p=Head->Next;p!=End;p=p->Next) for(k=p->Next;k!=End;k=k->Next) {
if(p->buyprice>k->buyprice) {
Goodsmessage::Swap(p,k); } }
Display();
out.open(\进货价.txt\
for(Goods *q=Head->Next;q!=End;q=q->Next)
out<
out.close();
cout<<\保存信息成功\ cout <<\排序完成!\ getch(); return; }
case 2: {
system(\
37
C++《超市商品管理系统》课程设计报告
cout <<\排序中...\ cout<<\
Goods *p=NULL,*p1=NULL,*k=NULL; int n=Goodsmessage::ListCount(); if(n<2) return;
for(p=Head->Next;p!=End;p=p->Next) for(k=p->Next;k!=End;k=k->Next) {
if(p->amount>k->amount) {
Goodsmessage::Swap(p,k); } }
Display();
out.open(\库存量.txt\
for(Goods *q=Head->Next;q!=End;q=q->Next)
out<
out.close();
cout<<\保存信息成功\ cout <<\排序完成!\ getch(); return; }
case 3: {
system(\
cout <<\排序中...\ cout<<\
Goods *p=NULL,*p1=NULL,*k=NULL; int n=Goodsmessage::ListCount(); if(n<2) return;
for(p=Head->Next;p!=End;p=p->Next) for(k=p->Next;k!=End;k=k->Next) {
if(p->profit>k->profit) {
Goodsmessage::Swap(p,k); } }
38
C++《超市商品管理系统》课程设计报告
Display();
out.open(\净利润.txt\
for(Goods *q=Head->Next;q!=End;q=q->Next)
out<
out.close();
cout<<\保存信息成功\ cout <<\排序完成!\ getch(); return; } } }
void Goodsmessage::Save() //﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌保存商品信息到文件函数﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌ {
out.open(\
for(Goods *p=Head->Next;p!=End;p=p->Next)
out<
out.close();
cout<<\保存信息成功\ }
int main() //﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌主函数﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌﹌ {
cout <<
\ for(int i = 0; i < 3; i ++)
cout<<\◎\\t\\t\\t\\t\\t\\t ◎\
cout<<\◎★★★★【 欢迎进入超市商品管理系统 】★★★★◎\<< endl;
for(i = 0; i < 3; i++)
cout<<\◎\\t\\t\\t\\t\\t\\t ◎\
39
C++《超市商品管理系统》课程设计报告
cout<<\ Goodsmessage Grade; cout<<\按任意键开始??\ getch(); int x; bool quit =false; while(!quit) { Grade.showMenu(2); cin>>x; switch(x) { case 0:{quit=true;break;} case 1:{Grade.AddItem();break;} case 2:{Grade.Display();break;} case 3:{Grade.Paixu();break;} case 4:{Grade.Find();break;} case 5:{Grade.RemoveItem();break;} case 6:{Grade.ModifyItem();break;} case 7:{Grade.Saleprice();break;} case 8:{Grade.Save();break;} } } return 0; } 40