public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int time;
int mealnum;
int comeback; //返回按钮
//菜单
String [] mealName = {"红烧茄子","红烧排骨","鱼香肉丝"};
double [] mealPrice = {24.0,36.0,32.0};
//餐袋信息
String [] listName = new String[10];//姓名
String [] listMeal = new String[10];//菜品
int [] listNum = new int[10];//数量
int [] listTime = new int[10];//时间
String [] listAddress = new String[10];//地址
double [] listMoney = new double[10];//总金额
String [] listFettle = new String[10];//订单状态
int [] likeNum = new int[3];//点赞数
int l = -1;
do {
//初始化菜单
System.out.println("欢迎使用外卖订餐系统");
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.println("请选择");
int choose = sc.nextInt();
int i;
switch (choose){
//我要订餐
case 1:
l++;//l初始值为-1,先自增再赋值
System.out.println("***我要订餐***");
System.out.println("请输入订餐人姓名:");
listName[l] = sc.next();
System.out.println("序号\t菜名\t单价");
System.out.println("1\t红烧茄子\t24.0元");
System.out.println("2\t红烧排骨\t36.0元");
System.out.println("3\t鱼香肉丝\t32.0元");
System.out.println("请选择你要点的菜品编号:");
i = sc.nextInt();
//对i进行判断
if(i>=1&&i<=3){
System.out.println("请选择你需要的份数:");
listNum[l] = sc.nextInt();
System.out.println("请输入送餐时间(送餐时间是10点至20点间整点送餐:)");
listTime[l] = sc.nextInt();
//对送餐时间进行判断
if(listTime[l]>=10&&listTime[l]<=20){
System.out.println("请输入送餐地址:");
listAddress[l] = sc.next();
System.out.println("订餐成功");
System.out.println("您订的是" + mealName[i-1] + listNum[l] + "份");
System.out.println("送餐时间:" + listTime[l] + "点");
System.out.println("餐费:" + mealPrice[i-1] * listNum[l] + "元,送餐费" + 3*listNum[l]+",总计:"+(mealPrice[i-1] * listNum[l]+3*listNum[l]) );
listMeal[l] = mealName[i-1];
listMoney[l] = mealPrice[i-1] * listNum[l]+3*listNum[l];
listFettle[l] ="已预订";
}else{
System.out.println("不在配送时间哦");
//删除错误的订单
listName[l] = null;
listNum[l] = 0;
listTime[l] = 0;
l--;
}
}else{
System.out.println("请输入正确的编号");
//删除错误的订单
listName[l] = null;
l--;
}
System.out.println("输入0返回");
comeback = sc.nextInt();
break;
//查看餐袋
case 2:
System.out.println("***查看餐袋***");
System.out.println("序号\t订餐人\t餐品信息\t份数\t送餐日期\t送餐地址\t总金额\t订单状态");
for (int k=0;k<=l;k++){
System.out.println((k+1)+"\t\t" +listName[k]+"\t\t" +listMeal[k]+"\t\t"+listNum[k]+"\t\t"+listTime[k]+"\t\t"+listAddress[k]+"\t\t"+listMoney[k]+"\t\t"+listFettle[k]);
}
System.out.println("输入0返回");
comeback = sc.nextInt();
break;
//签收订单
case 3:
System.out.println("***签收订单***");
System.out.println("请选择要签收的订单序号:");
int j = sc.nextInt();
if(listFettle[j-1].equals("已预订")){
System.out.println("订单签收成功");
listFettle[j-1] = "已签收";
}else {
System.out.println("该订单已经被签收");
}
System.out.println("输入0返回");
comeback = sc.nextInt();
break;
//删除订单
case 4:
System.out.println("***删除订单***");
System.out.println("请输入要删除的订单序号:");
int k =sc.nextInt();
if(!listName[k-1].equals(null)){
for(int m=k-1;m<=l;m++){
listName[m] = listName[m+1];
listMeal[m] = listMeal[m+1];
listNum[m] = listNum[m+1];
listTime[m] = listTime[m+1];
listAddress[m] = listAddress[m+1];
listMoney[m] = listMoney[m+1];
listFettle[m] = listFettle[m+1];
}
listName[l] = null;
listMeal[l] = null;
listNum[l] = 0;
listTime[l] = 0;
listAddress[l] = null;
listMoney[l] =0.0;
listFettle[l] = null;
System.out.println("删除订单成功!");
}else{
System.out.println("该订单不存在");
}
System.out.println("输入0返回");
comeback = sc.nextInt();
break;
//点赞系统
case 5:
System.out.println("***我要点赞***");
System.out.println("序号\t菜名\t单价");
System.out.println("1\t红烧茄子\t24.0元"+likeNum[0]+"赞");
System.out.println("2\t红烧排骨\t36.0元"+likeNum[1]+"赞");
System.out.println("3\t鱼香肉丝\t32.0元"+likeNum[2]+"赞");
System.out.println("请选择你要点赞的菜品序号:");
int m = sc.nextInt();
if(1<=m&&m<=3){
likeNum[m-1]++;
System.out.println("点赞成功");
}else{
System.out.println("点赞失败,请输入正确的菜品序号");
}
System.out.println("输入0返回");
comeback = sc.nextInt();
break;
//退出
case 6:
System.out.println("谢谢使用,欢迎下次光临!");
comeback =1;
break;
}
}while (comeback == 0);
}
基于javese的外卖订餐系统
最新推荐文章于 2023-10-29 22:41:28 发布