package Order;
import javax.print.attribute.standard.OrientationRequested;
import java.awt.*;
import java.util.*;
public class Test {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
Map<Integer, Dish> dishMap = new HashMap<Integer, Dish>();
Map<Integer, Order> orderMap = new HashMap<Integer, Order>();
//初始化菜品并添加菜品集合
Dish dish1 = new Dish(1, "鱼香肉丝", 35, 1);
Dish dish2 = new Dish(2, "宫保鸡丁", 30, 0);
Dish dish3 = new Dish(3, "回锅肉", 42, 0);
Dish dish4 = new Dish(4, "地锅鸡", 35, 0);
Dish dish5 = new Dish(5, "麻婆豆腐", 12, 0);
Dish dish6 = new Dish(6, "黄焖鸡", 21, 0);
dishMap.put(dish1.getDishId(), dish1);
dishMap.put(dish2.getDishId(), dish2);
dishMap.put(dish3.getDishId(), dish3);
dishMap.put(dish4.getDishId(), dish4);
dishMap.put(dish5.getDishId(), dish5);
dishMap.put(dish6.getDishId(), dish6);
//初始化订单
Order order1 = new Order(1, "薛立阳", dish1.getDishName(), 1, 10, "北大青鸟", dish1.getPrice() * 1, 0);
Order order2 = new Order(2, "薛立阳", dish2.getDishName(), 1, 10, "北大青鸟", dish2.getPrice() * 1, 1);
orderMap.put(order1.getOrderId(), order1);
orderMap.put(order2.getOrderId(), order2);
int count=2;
//菜单
int choose = 1; //用户输入
boolean isExit = false; //是否退出,true为退出
do {
System.out.println("****************");
System.out.println("1、我要订餐");
System.out.println("2、查看餐袋");
System.out.println("3、签收订单");
System.out.println("4、删除订单");
System.out.println("5、我要点赞");
System.out.println("6、退出系统");
System.out.println("****************");
System.out.print("请选择:");
choose = sc.nextInt();
//判断
switch (choose) {
case 1:
System.out.println("我要订餐---");
//新增订单
Order newOrder = new Order();
System.out.println("请输入订餐人姓名:");
newOrder.setName(sc.next());
//展示菜品信息
System.out.println("菜品编号" + "\t菜品名" + "\t\t价格" + "\t\t点赞数");
for (Dish dish : dishMap.values()) {
System.out.println(dish.getDishId() + "\t\t" + dish.getDishName() + "\t\t" + dish.getPrice() + "\t\t" + (dish.getPraise() == 0 ? "" : dish.getPraise() + "赞"));
}
System.out.print("请选择菜品编号:");
int chooseId=sc.nextInt();
if(chooseId>dishMap.size()){
System.out.println("不存在的菜品,请重新点单:");
chooseId=sc.nextInt();
}
newOrder.setOrderId(chooseId);
System.out.print("请选择需要份数:");
newOrder.setCount(sc.nextInt());
System.out.println("请输入送餐时间(送餐时间是10点至20点间整点送餐):");
newOrder.setTime(sc.nextInt());
//判断是否在配送规定时间
while (newOrder.getTime() < 10 || newOrder.getTime() > 21) {
System.out.println("您的输入有误,请输入10-20间的整数");
newOrder.setTime(sc.nextInt());
}
System.out.println("请输入送餐地址:");
newOrder.setAddress(sc.next());
//结算金额
newOrder.setSumPrice(newOrder.getCount() * dishMap.get(chooseId).getPrice());
if (newOrder.getSumPrice() < 50) {
//如果金额小于50加五元配送费
System.out.println("总金额不足50,须加5元配送费");
newOrder.setSumPrice(newOrder.getSumPrice() + 5);
}
//打印信息
System.out.println("创建订单成功!");
System.out.println("您定的是:" + dishMap.get(newOrder.getOrderId()).getDishName() +"("+dishMap.get(newOrder.getOrderId()).getPrice()+"元)\t" + newOrder.getCount() + "份\n送餐时间是:" + newOrder.getTime() + "\n总计:" + newOrder.getSumPrice() + "元");
count++;
newOrder.setOrderId(count);
//存入数据
orderMap.put(newOrder.getOrderId(), newOrder);
break;
case 2:
System.out.println("***查看餐袋***");
System.out.println("序号\t订餐人\t\t送餐时间\t\t送餐地址\t\t总金额\t订单状态");
for (Order order : orderMap.values()) {
System.out.println(order.getOrderId() + "\t" + order.getName() + "\t\t" +
order.getTime() + "\t\t\t" + order.getAddress() + "\t\t" + order.getSumPrice() +
"\t\t" + (order.getState() == 0 ? "已预订" : "已送达"));
}
break;
case 3:
System.out.println("****签收订单****");
System.out.print("请输入要签收的订单号:");
int id = sc.nextInt();
if(id>orderMap.size()){
System.out.println("该订单不存在");
}else if(orderMap.get(id).getState() == 0){
System.out.println("签收成功");
orderMap.get(id).setState(1);
}else if(orderMap.get(id).getState() == 1){
System.out.println("订单已签收,不能重复签收");
orderMap.get(id).setState(1);
}
break;
case 4:
System.out.println("***删除订单***");
System.out.print("请输入要删除的订单号:");
int delId = sc.nextInt();
boolean isDel=false;
//查询订单
for (int i = 1; i <= count; i++) {
//未签收
if(delId==i&&orderMap.get(i)!=null&&orderMap.get(i).getState()==0){
System.out.println("订单未签收,无法删除");
}else if(delId==i&&orderMap.get(i)!=null&&orderMap.get(i).getState()==1){
int j;
for ( j = i; j < count; j++) {
orderMap.put(j,orderMap.get(j+1)); //订单位置前移
}
orderMap.remove(j);
count--;
isDel=true;
System.out.println("删除成功");
break;
}
}
if(!isDel){
System.out.println("不存在的订单");
}
break;
case 5:
System.out.println("***我要点赞***");
//显示菜品信息
System.out.println("菜品编号" + "\t菜品名" + "\t\t价格" + "\t\t点赞数");
for (Dish dish : dishMap.values()) {
Sys
远离bug,珍爱头发
- 粉丝: 4023
- 资源: 8
最新资源
- AllSort(直接插入排序,希尔排序,选择排序,堆排序,冒泡排序,快速排序,归并排序)
- 模拟qsort,改造冒泡排序使其能排序任意数据类型,即日常练习
- 数组经典习题之顺序排序和二分查找和冒泡排序
- 基于 Oops Framework 提供的游戏项目开发模板,项目中提供了最新版本 Cocos Creator 3.x 插件与游戏资源初始化通用逻辑
- live-ai这是一个深度学习的资料
- FeiQ.rar 局域网内通信服务软件
- 172.16.100.195
- 光储并网simulink仿真模型,直流微电网 光伏系统采用扰动观察法是实现mppt控制,储能可由单独蓄电池构成,也可由蓄电池和超级电容构成的混合储能系统,并采用lpf进行功率分配 并网采用pq控制
- python编写微信读取smart200plc的数据发送给微信联系人
- 光储并网VSG系统Matlab simulink仿真模型,附参考文献 系统前级直流部分包括光伏阵列、变器、储能系统和双向dcdc变器,后级交流子系统包括逆变器LC滤波器,交流负载 光储并网VSG系
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
评论0