1、面向对象程序设计A课程设计本页仅作为文档封面,使用时可以删除 This document is for reference only-rar21year.March面向对象程序设计A课程设计(总25页)面向对象程序课程设计(2017/2018学年第二学期第17周)指导教师: XXX班级:XXX学号:XXXX姓名:XXX 面向对象程序课程设计任务书【题目】自助点餐系统【目的】通过设计一个小型的自助点餐系统,训练综合运用所学知识处理实际问题的能力,强化面向对象的程序设计理念,使自己的程序设计与调试水平有一个明显的提高。【要求】1、每个学生必须独立完成;2、课程设计时间为1周;3、设计语言采用C+;
2、4、学生有事离校必须请假。课程设计期间,无故缺席按旷课处理;缺席时间达四分之一以上者,未按规定上交实验报告的学生,其成绩按不及格处理。【内容简介】 有一个小型餐厅,现在这个餐厅打算使用自助点餐系统,方便顾客自己点餐,并提供对餐厅销售情况的统计和管理功能。【考核标准】该系统为两种角色的用户提供服务,一种是餐厅管理员,一种是顾客。餐厅管理员根据账号、密码登录系统。顾客无需登录即可使用系统。1、顾客通过该餐厅在系统中提供的菜单为自己点餐,菜单以文件形式保存。系统能够根据顾客的要求正确打出订单,订单内容包括订单编号、菜品名称、每个菜品的价格、份数、折扣等;订单分两种,一种是在店消费,在店消费要求包括餐
3、桌号,是否有包厢费,另一种是外卖,外卖要求包括送餐时间,送餐地点,客户手机号,外卖服务费。(要求用继承和多态实现),成绩60;2、系统退出后能保存当天的订单信息,要求每天一个文档,文档名按照日期命名。餐厅管理员可以根据订单编号查找删除修改某个订单,订单可以按照下单时间先后排序,成绩70;3、能够实现对餐厅菜式和价格的管理,包括对菜品和对应价格的增加、修改、删除、查找,折扣的设置,成绩80;4、系统可根据历史记录对销售情况进行统计,根据餐厅管理员的输入日期统计某天的销售情况并显示(包括一共接了多少单,销售额是多少,各个菜品的销售情况,外卖和在店销售的占比),成绩90;要求:用面向对象的程序设计方
4、法设计该系统。本系统涉及的基本对象有订单对象(包括外卖订单和在店消费订单)、订单管理对象、菜单对象、菜品对象、菜品管理对象、系统界面。实现对这些对象的合理抽象和封装,正确定义类之间的关系。界面合理,代码文件组织清晰,命名符合规范,代码注释清楚,课程设计报告质量高。面向对象程序课程设计一、题目有一个小型餐厅,现在这个餐厅打算使用自助点餐系统,方便顾客自己点餐,并提供对餐厅销售情况的统计和管理功能。二、需求分析有一个小型餐厅,该餐厅提供即时就餐和外卖服务。方便顾客自己点餐,并提供对餐厅销售情况的统计和管理功能。1、根据顾客的选择正确打出订单。2、统计出每一天的订单并将之保存在文件中。3、可以通过管
5、理员功能对订单,菜品等进行操作。三、系统结构图四、类的设计五、程序代码与说明#ifndef Face_h#define Face_h#include class Faceprivate: OrderMana shard;public: void start(); 理员ttt endl; cout ttt2.顾客ttt endl; cout _ m; if (m = 1) Adm(); int i; cin i; switch (i) case 1:AdmOrder(); break; case 2:AdmVege(); break; case 3:AdmSell(); break; case
6、4:break; else client(); 找修改删除订单 endl; cout ttt2.菜式和价格的管理 endl; cout ttt3.查看销售情况 endl; cout ttt4.退出 endl; cout _ i; switch (i) case 1:AdmOrder(); break; case 2:AdmVege(); break; case 3:AdmSell(); break; case 4:start(); break; start();找订单 endl; cout ttt2.修改订单 endl; cout ttt3.删除订单 endl; cout ttt4.退出 en
7、dl; cout _ i; switch (i) case 1:AdmOrderI(); break; case 2:AdmOrderII(); break; case 3:AdmOrderIII(); break; case 4:Adm1(); break; Adm1();加菜品 endl; cout ttt2.修改菜品 endl; cout ttt3.删除菜品 endl; cout ttt4.查找菜品 endl; cout ttt5.设置折扣 endl; cout ttt6.退出 endl; cout _ i; switch (i) case 1:AdmVegeI(); break; ca
8、se 2:AdmVegeII(); break; case 3:AdmVegeIII(); break; case 4:AdmVegeV(); break; case 5:AdmVegeVI(); break; case 6:Adm1(); break; Adm1();xt; OrderMana pe; (day); cout 订单数: ()endl; cout 销售额: () endl; cout 外卖和在店销售的占比: () endl; Adm1();卖 endl; cout ttt2.在店消费 i; if (i = 1) string time, address, phone; cout
9、 请输入送餐时间: time; cout 请输入送餐地点: address; cout 请输入手机号: phone; number = (); cout ttt外卖 endl; cout ttt编号: number endl; cout 送餐时间: time t送餐地点: address t客户手机号: phone endl; cout 菜品tt价格tt份数tt折扣 endl; (); list:iterator it; for (it = it != it+) money = (*it)-getmoney()*(*it)-getnum()*(*it)-getdiscount()* + mon
10、ey; cout 总价: money + 5 元 endl; (&pe, time, address, phone,number); else if (i = 2) cout i; bool r = 0; if (i = 是) r = 1; int c; srand(unsigned)time(NULL); c = rand() % (50 - 1); number = (); cout ttt在店消费 endl; cout ttt订单编号: number endl; cout 包厢费: (int)r * 50 元 endl; cout 座位号: c endl; cout 菜品tt价格tt份数
11、tt折扣 endl; (); list:iterator it; for (it = it != it+) money = (*it)-getmoney()*(*it)-getnum()*(*it)-getdiscount()* + money; cout 总价: money + (int)r * 50 元 endl; (&pe, r, c, number); start();xt, ios:trunc); for (it = it != it+) outDate getname() tt getmoney() tt getdiscount() endl; (); cout 添加成功 endl
12、; AdmVege();xt, ios:trunc); for (it = it != it+) outDate getname() tt getmoney() tt getdiscount() endl; (); cout 修改成功 endl; AdmVege();xt, ios:trunc); for (it = it != it+) outDate getname() tt getmoney() tt getdiscount() endl; (); cout 删除成功 endl; AdmVege();xt, ios:trunc); for (it = it != it+) outDate
13、 getname() tt getmoney() tt getdiscount() endl; (); cout 修改成功 endl; AdmVege();xt; cout numble; OrderMana pe; (day); (numble); AdmOrder();xt; cout numble; OrderMana pe; (day);xt; cout numble; OrderMana pe; (day); ofstream outDate(day, ios:trunc); list:iterator it; for (it = it != it+) if (*it)-getKin
14、d() = 外卖) outDate ttt外卖 endl; outDate ttt编号 getNumble() endl; outDate 送餐时间: getTim() t送餐地点: getAddress() t客户手机号: getphone() endl; outDate 菜品tt价格tt份数tt折扣 endl; list:iterator I; for (I = (*it)-(); I != (*it)-(); it+) outDate getname() tt getmoney() tt getnum()ttgetdiscount() endl; outDate 总价: getAllmo
15、ney() 元 endl; else outDate ttt在店消费 endl; outDate ttt订单编号: getNumble() endl; outDate 包厢费: getA() * 50 元 endl; outDate 座位号: getTable() endl; outDate 菜品tt价格tt份数tt折扣 endl; list:iterator I; for (I = (*it)-(); I != (*it)-(); it+) outDate getname() tt getmoney() tt getnum() tt getdiscount() endl; outDate 总
16、价: getAllmoney() 元 endl; (); cout 删除成功 endl;#include #include #include #include #include using namespace std;void main() Face re; ();#include Mana:Mana(string numble, string kind, string tim, string address, string phone) this-Numble = numble; this-kind = kind; this-tim = tim; this-address = address
17、; this-phone = phone;Mana:Mana(string numble, string kind, int table, bool a) this-Numble = numble; this-kind = kind; this-table = table; this-a = a;void Mana:setAllmoney(int money) Allmoney = money;void Mana:insert(string Vege, double money, int num, double discount) list:iterator it; *it = new Veg
18、etalbe(Vege, money, num, discount); (*it);#include #include #include #include using namespace std;xt); string name; double money; double discount; infile name money discount; p = new Vegetalbe(name, money, discount); while (!() (p); infile name money discount; p = new Vegetalbe(name, money, discount
19、); ();void Menu:pushnew(Vegetalbe &b) p = &b; (p);string Menu:number() time_t t = time(0); char tmp32 = NULL ; strftime(tmp, sizeof(tmp), %Y%m%d%H%M%S, localtime(&t); return tmp;void Menu:dleinsert(string Vege) list:iterator it; for (it = (); it != (); it+) if (*it)-getname() != Vege) (*it); void Me
20、nu:insert(string Vege, double money, int num, double discount) list:iterator it; *it = new Vegetalbe(Vege, money, num, discount); (*it);Menu:Menu() list:iterator it; for (it = (); it != (); it+) delete *it; for (it = (); it != (); it+) delete *it; #include #include using namespace std;Order:Order(st
21、ring account, string code) this-account = account; this-code = code;bool Order:judge() bool T = 0; ifstream infile(D:管理员账号.txt); string Account, Code; while (!() infile Account Code; if (this-account = Account) | (this-code = Code) T = 1; break; (); return T;#include #include #include #include using
22、 namespace std;xt; ofstream outDate(day, ios:app); double money = 0; outDate endl ttt外卖 endl; outDate ttt订单编号 number endl; outDate 送餐时间 tim t送餐地点 address t客户手机号 phone endl; list:iterator it; for (it = p-(); it != p-(); it+) outDate getname() tt getmoney() tt getnum() tt getdiscount() getmoney()*(*it)-getnum()*(*it)-getdiscount()* + money; outDate 总价 money+5endl; ();xt; ofstream outDate(day, ios:app); double money = 0; outDate endl ttt在店消费 endl; if (a = 1) outDate ttt订单编号 number endl; outDate 包厢费 (int)a * 50