C language realizes ordering system
- 2020-06-23 01:11:19
- OfStack
This article shares the specific code of C language ordering system for your reference. The specific content is as follows
#include<iostream>
#include<fstream>
#include<string>
#include<conio.h>
using namespace std;
class shiwu
{
public:
string mingzi;
int price;
shiwu(){}
shiwu(string n,int p):mingzi(n),price(p){}
};
shiwu zhucan[3]={shiwu(" Big hamburger ",13),shiwu(" Roast dinner ",13),shiwu(" Chicken book ",11)};
shiwu fushi[3]={shiwu(" Spicy chicken nail ",9),shiwu(" Fried chicken and rice ",9),shiwu(" Large fries ",6)};
shiwu drink[3]={shiwu(" Coca-Cola ",5),shiwu(" latte ",6),shiwu(" Hot milk ",6)};
class Taocan
{
public:
string mingzi;
shiwu tc[3];
int price;
Taocan(){}
Taocan(string n,shiwu a,shiwu b,shiwu c)
{
mingzi=n;
tc[0]=a;
tc[1]=b;
tc[2]=c;
price=a.price+b.price+c.price-10;
}
};
Taocan taocan[3]={Taocan(" Set with chicken legs and wings ",zhucan[0],fushi[0],drink[0]),Taocan(" Cod, chicken and rice with flowers ",zhucan[1],fushi[1],drink[0]),Taocan(" Chicken wrap and fries combo ",zhucan[2],fushi[2],drink[0])};
shiwu myshiwu[13];
int mymoney;
int mynum=0;
void write()
{
ofstream f("list.txuant");
int i;
f << "KFC Consumer list \n";
for(i=0;i<mynum;i++)
f<<i+1<<" , "<<myshiwu[i].mingzi<<" Price: "<<myshiwu[i].price<<endl;
f<<" The total price, "<<mymoney<<endl;
f<<endl<<endl;
f.close();
system("list.txuant");
}
void xuanzhucan()
{
void Menu();
void Diancan();
system("cls");
cout<<"1 , "<<zhucan[0].mingzi<<" Price: "<<zhucan[0].price<<endl;
cout<<"2 , "<<zhucan[1].mingzi<<" Price: "<<zhucan[1].price<<endl;
cout<<"3 , "<<zhucan[2].mingzi<<" Price: "<<zhucan[2].price<<endl;
cout<<"4 , return "<<endl;
char c;
c=getch();
switch(c)
{
case '1': myshiwu[mynum]=zhucan[0];mymoney+=zhucan[0].price;mynum++; break;
case '2': myshiwu[mynum]=zhucan[1];mymoney+=zhucan[1].price;mynum++; break;
case '3': myshiwu[mynum]=zhucan[2];mymoney+=zhucan[2].price;mynum++; break;
case '4': Diancan(); break;
default:
printf("\n Your key is wrong, press any key to select again! \n");
getch();
xuanzhucan();
}
printf("\n Order successfully! Press any key to continue or return! \n");
getch();
if(mynum>10)
{
cout<<" Your order has reached the limit! If necessary! Please continue your order after you settle your account! "<<endl;
printf("\n Press any key to enter the menu! \n");
getch();
Menu();
}
else xuanzhucan();
}
void xuanfushi()
{
void Menu();
void Diancan();
system("cls");
cout<<"1 , "<<fushi[0].mingzi<<" Price: "<<fushi[0].price<<endl;
cout<<"2 , "<<fushi[1].mingzi<<" Price: "<<fushi[1].price<<endl;
cout<<"3 , "<<fushi[2].mingzi<<" Price: "<<fushi[2].price<<endl;
cout<<"4 , return "<<endl;
char c;
c=getch();
switch(c)
{
case '1': myshiwu[mynum]=fushi[0];mymoney+=fushi[0].price;mynum++; break;
case '2': myshiwu[mynum]=fushi[1];mymoney+=fushi[1].price;mynum++; break;
case '3': myshiwu[mynum]=fushi[2];mymoney+=fushi[2].price;mynum++; break;
case '4': Diancan(); break;
default:
printf("\n Your key is wrong, press any key to select again! \n");
getch();
xuanfushi();
}
printf("\n Order successfully! Press any key to continue or return! \n");
getch();
if(mynum>10)
{
cout<<" Your order has reached the limit! If necessary! Please continue your order after you settle your account! "<<endl;
printf("\n Press any key to enter the menu! \n");
getch();
Menu();
}
else xuanfushi();
}
void xuandrink()
{
void Menu();
void Diancan();
system("cls");
cout<<"1 , "<<drink[0].mingzi<<" Price: "<<drink[0].price<<endl;
cout<<"2 , "<<drink[1].mingzi<<" Price: "<<drink[1].price<<endl;
cout<<"3 , "<<drink[2].mingzi<<" Price: "<<drink[2].price<<endl;
cout<<"4 , return "<<endl;
char c;
c=getch();
switch(c)
{
case '1': myshiwu[mynum]=drink[0];mymoney+=drink[0].price;mynum++; break;
case '2': myshiwu[mynum]=drink[1];mymoney+=drink[1].price;mynum++; break;
case '3': myshiwu[mynum]=drink[2];mymoney+=drink[2].price;mynum++; break;
case '4': Diancan(); break;
default:
printf("\n Your key is wrong, press any key to select again! \n");
getch();
xuandrink();
}
printf("\n Order successfully! Press any key to continue or return! \n");
getch();
if(mynum>10)
{
cout<<" Your order has reached the limit! If necessary! Please continue your order after you settle your account! "<<endl;
printf("\n Press any key to enter the menu! \n");
getch();
Menu();
}
else xuandrink();
}
void Taocan()
{
void Menu();
void Diancan();
system("cls");
cout<<"1 , "<<taocan[0].mingzi<<" Price: "<<taocan[0].price<<endl;
cout<<"2 , "<<taocan[1].mingzi<<" Price: "<<taocan[1].price<<endl;
cout<<"3 , "<<taocan[2].mingzi<<" Price: "<<taocan[2].price<<endl;
cout<<"4 , return "<<endl;
char c;
c=getch();
switch(c)
{
case '1': mymoney+=taocan[0].price;myshiwu[mynum]=taocan[0].tc[0];mynum++;myshiwu[mynum]=taocan[0].tc[1];mynum++;myshiwu[mynum]=taocan[0].tc[2];mynum++; break;
case '2': mymoney+=taocan[1].price;myshiwu[mynum]=taocan[1].tc[0];mynum++;myshiwu[mynum]=taocan[1].tc[1];mynum++;myshiwu[mynum]=taocan[1].tc[2];mynum++; break;
case '3': mymoney+=taocan[2].price;myshiwu[mynum]=taocan[2].tc[0];mynum++;myshiwu[mynum]=taocan[2].tc[1];mynum++;myshiwu[mynum]=taocan[2].tc[2];mynum++; break;
case '4': Diancan(); break;
default:
printf("\n Your key is wrong, press any key to select again! \n");
getch();
Taocan();
}
printf("\n Order successfully! Press any key to continue or return! \n");
getch();
if(mynum>10)
{
cout<<" Your order has reached the limit! If necessary! Please continue your order after you settle your account! "<<endl;
printf("\n Press any key to enter the menu! \n");
getch();
Menu();
}
else Taocan();
}
void Diancan()
{
void Menu();
system("cls");
cout<<"1 The staple food, "<<endl;
cout<<"2 , snacks "<<endl;
cout<<"3 , drinks "<<endl;
cout<<"4 And package "<<endl;
cout<<"5 , return "<<endl;
char c;
c=getch();
switch(c)
{
case '1': xuanzhucan(); break;
case '2': xuanfushi(); break;
case '3': xuandrink(); break;
case '4': Taocan(); break;
case '5': Menu(); break;
default:
printf("\n Your key is wrong, press any key to select again! \n");
getch();
Diancan();
}
}
void Zhifu()
{
void Menu();
system("cls");
cout<<" Your current consumption "<<mymoney<<" Yuan! Cash, please! "<<endl;
int m,s;
cin>>m;
s=m-mymoney;
while(s<0)
{
cout<<" The cash you give is not enough, we still need it "<<0-s<<" Yuan! Please keep paying cash! "<<endl;
cin>>m;
s=m+s;
}
cout<<" Successful payment! The change "<<s<<" Yuan! Wish you a happy life! "<<endl;
write();
printf("\n Press any key to return to the menu! \n");
getch();
Menu();
}
void Youhuiquan()
{
void Menu();
system("cls");
printf("\n Please enter your coupon! \n");
string yhq;
cin>>yhq;
if(yhq=="156157158")
{
cout<<" You have successfully used it 5 Yuan coupon! "<<endl;
mymoney=mymoney-5;
}
else
{
cout<<" I'm sorry! Your coupon is invalid! "<<endl;
getch();
Menu();
}
getch();
Zhifu();
}
void Jiesuan()
{
void Menu();
system("cls");
cout<<"1 3. Use coupons "<<endl;
cout<<"2 , direct payment "<<endl;
cout<<"4 , return "<<endl;
char c;
c=getch();
switch(c)
{
case '1': Youhuiquan(); break;
case '2': Zhifu(); break;
case '4': Menu(); break;
default:
printf("\n Your key is wrong, press any key to select again! \n");
getch();
Diancan();
}
}
void Show()
{
void Menu();
system("cls");
int i;
for(i=0;i<mynum;i++)
cout<<i+1<<" , "<<myshiwu[i].mingzi<<" Price: "<<myshiwu[i].price<<endl;
cout<<" The total price, "<<mymoney<<endl;
printf("\n Press any key to return to the menu! \n");
getch();
Menu();
}
void Clean()
{
void Menu();
system("cls");
mynum=0;
mymoney=0;
printf("\n Clear success! \n Press any key to return to the menu! \n");
getch();
Menu();
}
void Menu()
{
system("cls");
cout<<endl<<endl<<" Welcome in! "<<endl<<endl;
cout<<" Please select service: "<<endl;
cout<<"1 Order, "<<endl;
cout<<"2 , check already clicked "<<endl;
cout<<"3 , empty already point "<<endl;
cout<<"4 , settlement "<<endl;
cout<<"5 , exit "<<endl;
char c;
c=getch();
switch(c)
{
case '1': Diancan(); break;
case '2': Show(); break;
case '3': Clean(); break;
case '4': Jiesuan(); break;
case '5': exit(0);
default:
printf("\n Your key is wrong, press any key to select again! \n");
getch();
Menu();
}
}
void main()
{
Menu();
}
For more information, please pay attention to the topic management System Development.