模拟肯德基快餐店的收银系统-模拟打印小票的功能
2023-09-02 10:02:51 欢乐点

一、题目名称:模拟麦当劳收银系统

二、题目内容:

朋友们应当都去肯德基或麦当劳吃过快餐吧?请朋友们参考麦当劳官网的信息模拟麦当劳快餐店的收银系统,合理使用C++或Java或结合设计模式(2种以上)起码实现系统的以下功能:

1.正常餐品结算和找零。

2.基本套餐结算和找零。

3.使用让利劵订购餐品结算和找零。

4.可在一定时间段参与店内活动(自行设计或参考官网信息)。

5.模拟复印小票的功能(讲到文件中)。

基本要求:

1.程序设计风格良好,控制台界面友好,最多四人一组完成任务。

工厂食堂点餐系统_饭堂点餐系统优点_工厂食堂操作流程文字说明

2.实现功能测试代码,确保程序的强壮性。

3.画出使用的设计模式图。

增强要求:

1.实现可视化界面(使用MFC)。

2.实现会员储值卡功能,完成储值卡消费。

实现当日营业额和餐品销量估算和统计,用数据库记录。

三、算法设计:

四、代码

1.点餐系统代码

工厂食堂点餐系统_工厂食堂操作流程文字说明_饭堂点餐系统优点

#include
#include
#include
using namespace std;
class Food
{
protected:
	string name;
	double price;
	int num;
public:
	virtual double get_sum()
	{
		double sum = price * num;
		return sum;
	}
	virtual void set_name(string name)
	{
		this->name = name;
	}
	virtual string get_name()
	{
		return name;
	}
	virtual void set_price(double price)
	{
		this->price = price;
	}
	virtual double get_price()
	{
		return price;
	}
	virtual void set_num(int num)
	{
		this->num = num;
	}
	virtual int get_num()
	{
		return num;
	}
};
class Hamburger :public Food
{
public:
	virtual double get_sum()
	{
		double sum = price * num;
		return sum;
	}
};
class Snack :public Food
{
public:
	virtual double get_sum()
	{
		double sum = price * num;
		return sum;
	}
};
class Drink :public Food
{
public:
	virtual double get_sum()
	{
		double sum = price * num;
		return sum;
	}
};
class Set :public Food
{
public:
	virtual double get_sum()
	{
		double sum = price * num;
		return sum;
	}
};
class Factory
{
public:
	virtual Food* food() = 0;
};
class Factory_Hamburger :public Factory
{
public:
	Food* food()
	{
		return new Hamburger;
	}
};
class Factory_Snack :public Factory
{
public:
	Food* food()
	{
		return new Snack;
	}
};
class Factory_Drink :public Factory
{
public:
	Food* food()
	{
		return new Drink;
	}
};
class Factory_Set :public Factory
{
public:
	Food* food()
	{
		return new Set;
	}
};
class xiaopiao
{
	public:
		virtual void output() = 0;
} ;
class H1 : public xiaopiao
{
public:
	void get_num(int n)
	{
		num = n;
	}
     void output()
     {
		  if(0 != num)
		  {
		  	ofstream outfile("receipt.dat", ios::out);
			cout << "巨无霸--" << num << "份" <<endl;
			outfile << "巨无霸--" << num << "份" << endl;
			outfile.close();
		  }
     }
protected:
	int num;
};
class H2 : public xiaopiao
{
public:
	void get_num(int n)
	{
		num = n;
	}
     void output()
     {
          
		  if(0 != num)
		  {
		  	ofstream outfile("receipt.dat", ios::out);
		  cout << "双层吉士汉堡--" << num << "份" <<endl;
		  outfile << "双层吉士汉堡--" << num << "份" << endl;
		  outfile.close();
		  }
     }
protected:
	int num;
};
class H3 : public xiaopiao
{
public:
	void get_num(int n)
	{
		num = n;
	}
     void output()
     {
          
		  if(0 != num)
		  {
		  	ofstream outfile("receipt.dat", ios::out);
		  cout << "麦辣鸡腿汉堡--" << num << "份" <<endl;
		  outfile << "麦辣鸡腿汉堡--" << num << "份" << endl;
		  outfile.close();
		  }
     }
protected:
	int num;
};
class S1 : public xiaopiao
{
public:
	void get_num(int n)
	{
		num = n;
	}
     void output()
     {
          
		  if(0 != num)
		  {
		  	ofstream outfile("receipt.dat", ios::out);
		  cout << "大薯条--" << num << "份" <<endl;
		  outfile << "大薯条--" << num << "份" << endl;
		  outfile.close();
		  }
		  
     }
protected:
	int num;
};
class S2 : public xiaopiao
{
public:
	void get_num(int n)
	{
		num = n;
	}
     void output()
     {
          
		  if(0 != num)
		  {
		  	ofstream outfile("receipt.dat", ios::out);
		  cout << "麦乐鸡--" << num << "份" <<endl;
		  outfile << "麦乐鸡--" << num << "份" << endl;
		  outfile.close();
		  }
     }
protected:
	int num;
};
class D1 : public xiaopiao
{
public:
	void get_num(int n)
	{
		num = n;
	}
     void output()
     {
          
		  if(0 != num)
		  {
		  	ofstream outfile("receipt.dat", ios::out);
		  cout << "可口可乐--" << num << "份" <<endl;
		  outfile << "可口可乐--" << num << "份" << endl;
		  outfile.close();
		  }
     }
protected:
	int num;
};
class D2 : public xiaopiao
{
public:
	void get_num(int n)
	{
		num = n;
	}
     void output()
     {
          
		  if(0 != num)
		  {
		  	ofstream outfile("receipt.dat", ios::out);
		  cout << "七喜--" << num << "份" <<endl;
		  outfile << "七喜--" << num << "份" << endl;
		  outfile.close();
		  }
     }
protected:
	int num;
};
class D3 : public xiaopiao
{
public:
	void get_num(int n)
	{
		num = n;
	}
     void output()
     {
          
		  if(0 != num)
		  {
		  	ofstream outfile("receipt.dat", ios::out);
		  cout << "橙汁--" << num << "份" <<endl;
		  outfile << "橙汁--" << num << "份" << endl;
		  outfile.close();
		  }
     }
protected:
	int num;
};
class SET1 : public xiaopiao
{
public:
	void get_num(int n)
	{
		num = n;
	}
     void output()
     {
          
		  if(0 != num)
		  {
		  	ofstream outfile("receipt.dat", ios::out);
		  cout << "巨无霸超值套餐--" << num << "份" <<endl;
		  outfile << "巨无霸超值套餐--" << num << "份" << endl;
		  outfile.close();
		  }
     }
protected:
	int num;
};
class SET2 : public xiaopiao
{
public:
	void get_num(int n)
	{
		num = n;
	}
     void output()
     {
          
		  if(0 != num)
		  {
		  ofstream outfile("receipt.dat", ios::out);
		  cout << "双层吉士汉堡超值套餐--" << 1 << "份" <<endl;
		  outfile << "双层吉士汉堡超值套餐--" << 1 << "份" << endl;
		  outfile.close();
		  }
     }
protected:
	int num;
};
//运用策略模式简化 
class Context
{
public:
     Context(xiaopiao *p) : pStrategy(p)
     {
     }
     void Interface()
     {
          pStrategy->output();
     }
private:
     xiaopiao *pStrategy;
};
class collect
{
private:
	
public:
	void main_menu()
	{
		cout << "---------------------" << endl;
		cout << "欢迎进入肯德基点餐系统!" << endl;
		cout << "---------------------" << endl;
		cout << "请问你选择单点(1)或者套餐(2):" << endl;
	}
	void single_menu()
	{
		cout << "---------------------" << endl;
		cout << "请选择您要点的产品:  " << endl;
		cout << "主食:				  " << endl;
		cout << " 1.巨无霸      --17元 " << endl;
		cout << " 2.双层吉士汉堡--15元 " << endl;
		cout << " 3.麦辣鸡腿汉堡--15元 " << endl;
		cout << "配餐:				  " << endl;
		cout << " 4.大薯条      --11元 " << endl;
		cout << " 5.麦乐鸡      --9元 " << endl;
		cout << "饮料:				  " << endl;
		cout << " 6.可口可乐    --7元 " << endl;
		cout << " 7.七喜	    --7元 " << endl;
		cout << " 8.橙汁      --10元 " << endl;
		cout << "若点餐结束,请输入0以结束点餐!" << endl;
	}
	void set_menu()
	{
		cout << "---------------------" << endl;
		cout << "请选择您要点的套餐:  " << endl;
		cout << " 1.巨无霸超值套餐   --25元" << endl;
		cout << " (包含巨无霸一份、大薯条一份、可口可乐一份)" << endl;
		cout << " 2.双层吉士汉堡超值套餐 --23元" << endl;
		cout << " (包含双层吉士汉堡一份、大薯条一份、可口可乐一份)" << endl;
		cout << "若点餐结束,请输入0以结束点餐!" << endl;
	}
	void menu()
	{
		main_menu();
		int choose;
		int hamburger[3], snack[2], drink[3],set[2];
		for (int i = 0; i < 3; i++) { hamburger[i] = 0; drink[i] = 0; }
		for (int i = 0; i < 2; i++) { snack[i] = 0; set[i] = 0; }
		cin >> choose;
		if (1 == choose)
		{
			single_menu();
			int ch,flag=1;
			while(flag)
			{
				cout << "请输入对应商品的序号:" ;
				cin >> ch;
				switch (ch)
				{
				case(0):
				{
					flag = 0;
					break;
				}
				case(1):
				{
					cout << "请输入需要几份?:";
					int number;
					cin >> number;
					hamburger[0] = number;
					break;
				}
				case(2):
				{
					cout << "请输入需要几份?:";
					int number;
					cin >> number;
					hamburger[1] = number;
					break;
				}
				case(3):
				{
					cout << "请输入需要几份?:";
					int number;
					cin >> number;
					hamburger[2] = number;
					break;
				}
				case(4):
				{
					cout << "请输入需要几份?:";
					int number;
					cin >> number;
					snack[0] = number;
					break;
				}
				case(5):
				{
					cout << "请输入需要几份?:";
					int number;
					cin >> number;
					snack[1] = number;
					break;
				}
				case(6):
				{
					cout << "请输入需要几份?:";
					int number;
					cin >> number;
					drink[0] = number;
					break;
				}
				case(7):
				{
					cout << "请输入需要几份?:";
					int number;
					cin >> number;
					drink[1] = number;
					break;
				}
				case(8):
				{
					cout << "请输入需要几份?:";
					int number;
					cin >> number;
					drink[2] = number;
					break;
				}
				default:
				{
					cout << "请输入正确的序号!" << endl;
					break;
				}
				}
			}
		}
		else if (2 == choose)
		{
			set_menu();
			int ch, flag = 1;
			while (flag)
			{
				cout << "请输入对应商品的序号:";
				cin >> ch;
				switch (ch)
				{
				case(0):
				{
					flag = 0;
					break;
				}
				case(1):
				{
					cout << "请输入需要几份?:";
					int number;
					cin >> number;
					set[0] = number;
					break;
				}
				case(2):
				{
					cout << "请输入需要几份?:";
					int number;
					cin >> number;
					set[1] = number;
					break;
				}
				
				default:
				{
					cout << "请输入正确的序号!" << endl;
					break;
				}
				}
			}
		}
		//生成汉堡工厂类
		Factory_Hamburger* fac_h = new Factory_Hamburger();
		//生成具体的汉堡类
		Food* hamburger1 = fac_h->food();
		Food* hamburger2 = fac_h->food(
					
					

免责声明:部分文章信息来源于网络以及网友投稿,本站只负责对文章进行整理、排版、编辑,出于传递更多信息之目的,并不意味着赞同其观点或证实其内容的真实性,如本站文章和转稿涉及版权等问题,请作者在及时联系本站,我们会尽快为您处理。

欢乐点

留言咨询

×