for (int j = 0; jdishNames.length; j++) {
System.out.println(
(j + 1) + "\t" + dishNames[j] + "\t\t" + prices[j] + "元" + "\t" + praiseNums[j]);
}
System.out.print("请选择您要点的菜品编号:");
int chooseDish = input.nextInt();
String dishMeg = dishNames[chooseDish - 1];
System.out.print("请选择您需要的份数:");
int number = input.nextInt();
System.out.print("请输入送餐时间(送餐时间是10点至20点间整点送餐):");
int time = input.nextInt();
while (time10 || time20) {
System.out.print("您的输入有误,请输入10-20间的整数");
time = input.nextInt();
}
System.out.print("请输入送餐地址:");
String address = input.next();
// 默认可以预定,不用写订单状态
System.out.println("订餐成功!");
System.out.println("您定的是:" + dishNames[chooseDish - 1] + number + "份");
System.out.println("送餐时间:" + time + "点");
double sumPrice = prices[chooseDish - 1] * number;// 计算餐费
double sendMoney = (sumPrice = 50) ? 0 : 5;// 计算送餐费
System.out.println("餐费:" + sumPrice + "元," + "送餐费" + sendMoney + "元," + "总计:"
+ (sumPrice + sendMoney) + "元 。");
// 添加数据
names[i] = name;
dishMegs[i] = dishMeg;
times[i] = time;
dishNums[i] = number;
addresses[i] = address;
sumPrices[i] = sumPrice + sendMoney;
break;
}
if (isAdd) {
System.out.println("对不起,您的餐袋已满!");
}
}
break;
case 2:// 查看餐袋
System.out.println("***查看餐袋***");
System.out.println("序号\t订餐人\t餐品名称\t餐品数量\t送餐时间\t送餐地址\t总金额\t订单状态");
for (int i = 0; inames.length; i++) {
if (names[i] != null) {
String state = (states[i] == 0) ? "已预订" : "已完成";
System.out.println((i + 1) + "\t" + names[i] + "\t" + dishMegs[i] + "\t" + dishNums[i] + "份"
+ "\t" + times[i] + "\t" + addresses[i] + "\t" + sumPrices[i] + "元" + "\t" + state);
}
}
break;
case 3:// 签收订单
System.out.println("***签收订单***");
boolean isSignFind = false;
System.out.print("请选择要签收的订单序号:");
int sign = input.nextInt();
for (int i = 0; inames.length; i++) {
if (names[i] != nullstates[i] == 0sign == i + 1) {
states[i] = 1;
System.out.println("订单签收成功!");
isSignFind = true;// 标记已找到的订单
} else if (names[i] != nullstates[i] == 1sign == i + 1) {
System.out.println("您选择的订单已完成签收 , 不能再次签收!");
isSignFind = true;// 标记已找到的订单
}
}
if (!isSignFind) {
System.out.println("您选择的订单不存在!");
}
break;
case 4:// 删除订单
System.out.println("***删除订单***");
boolean isDelFind = false;
System.out.print("请输入要删除的订单序号:");
int delID = input.nextInt();
for (int i = 0; inames.length; i++) {
// 根据状态值判断能不能删除,只有已完成的才能删除
if (names[i] != nullstates[i] == 1delID == i + 1) {
isDelFind = true;
for (int j = delID - 1; jnames.length - 1; j++) {
names[j] = names[j + 1];
dishMegs[j] = dishMegs[j + 1];
dishNums[j] = dishNums[j + 1];
times[j] = times[j + 1];
addresses[j] = addresses[j + 1];
states[j] = states[j + 1];
sumPrices[j] = sumPrices[j + 1];
}
// 将最后一位清空
names[names.length - 1] = null;
dishMegs[names.length - 1] = null;
dishNums[names.length - 1] = 0;
times[names.length - 1] = 0;
addresses[names.length - 1] = null;
states[names.length - 1] = 0;
sumPrices[names.length - 1] = 0;
推荐阅读
- cad说未安装net怎么办,cad未安装net35
- gis怎么保留所选的要素,arcgis单独保存选中要素
- 变色龙引导虚拟机,变色龙引导黑苹果教程
- 在线课堂教学视频钉钉直播,钉钉课堂在线直播教程
- 爱租机支付宝小程序二维码,支付宝里爱租机租完即送是怎么回事
- natio口红flutter,t f 口红
- pg数据库更换位置,pg数据库修改字段名
- 虚拟机怎么测试mysql 虚拟机怎么测试用户权限
- u盘里的光盘是什么材料,u盘是什么材料做的