1 package com.eat; 2 3 import java.util.Scanner; 4 5 public class EatSystem { 6 public static void main(String[] args) { 7 Scanner sc = new Scanner(System.in); 8 System.out.println("欢迎使用“吃货联盟订餐系统”"); 9 String choose = "";//菜单选择的变量 10 //初始化数据 11 int length = 5; 12 String[] names = new String[length];//订餐人 13 String[] descs = new String[length];//订单餐品信息 14 int[] dates =new int[length];//送餐日期 15 String[] addresses = new String[length];//送餐地址 16 double[] moneys = new double[length];//总价 17 boolean[] status = new boolean[length];//订餐状态:true:完成;false未完成 18 int[] nums = new int[length];//订餐数量 19 double[] prices = new double[10];//单价 20 String[] foods = new String[10];//菜品信息 21 int[] zan = new int[10];//点赞数量 22 zan[0] = 12;zan[2] = 5;zan[4]=25; 23 foods[0] = "黄焖鸡";foods[1] = "东坡肉";foods[2] = "蛋炒饭";foods[3] = "北京烤鸭";foods[4] = "大肘子"; 24 prices[0] = 16.0;prices[1] = 15.5;prices[2] = 8.0;prices[3] = 49.9;prices[4] = 18.8; 25 //初始化两条信息 26 names[0] = "张三"; 27 descs[0] = "黄焖鸡"; 28 nums[0] = 2; 29 moneys[0] = 32.0; 30 dates[0] = 7; 31 addresses[0] = "北京路18号"; 32 status[0] = true; 33 34 names[1] = "李四"; 35 descs[1] = "东坡肉"; 36 nums[1] = 3; 37 moneys[1] = 46.5; 38 dates[1] = 8; 39 addresses[1] = "北京路18号"; 40 status[1] = false; 41 42 do { 43 System.out.println("******************************"); 44 System.out.println("1、我要订餐 2、查看餐袋 3、签收订单 4、删除订单 5、我要点赞 6、退出系统"); 45 System.out.println("请选择:"); 46 choose = sc.next(); 47 switch (choose) { 48 case "1": 49 System.out.println("****我要订餐****"); 50 int index = -1;//定义要添加的位置下标 51 for(int i = 0 ;imax) { 76 System.out.println("不存在此编号菜品,请重新输入:"); 77 } 78 } while (id<1||id>max); 79 descs[index] = foods[id-1]; 80 System.out.println("请选择您需要的份数:"); 81 int num = sc.nextInt(); 82 nums[index] = num; 83 System.out.println("请输入送餐时间(送餐时间是10点至20点间整点送餐)"); 84 int date = 0; 85 do { 86 date = sc.nextInt(); 87 if(date<10||date>20) { 88 System.out.println("您的输入有误,请输入10~20间的整数!:"); 89 } 90 } while (date<10||date>20); 91 dates[index] = date; 92 System.out.println("请输入送餐地址:"); 93 addresses[index] = sc.next(); 94 double money = prices[id-1]*num; 95 System.out.println("订餐成功:"); 96 System.out.println("您订的是:"+foods[id-1]+" "+num+"份"); 97 System.out.println("送餐时间:"+date+"点"); 98 double song = 0.0; 99 if(money<20) {100 song = 3.0;101 }102 moneys[index] = money+song;103 System.out.println("餐费:"+money+"。送餐费:"+song+"元,总计:"+(money+song)+"元");104 }105 106 break;107 case "2":108 System.out.println("****查看餐袋****");109 System.out.println("序号\t订餐人\t餐品信息\t\t送餐日期\t\t送餐地址\t\t总金额\t订单状态");110 for(int i = 0;i descs.length) {127 isTrue = true;128 }else {129 if(descs[id-1]==null) {130 isTrue = true;131 }else {132 isTrue = false;133 }134 }135 136 if(isTrue) {137 System.out.println("不存在此编号的订单信息,请重新输入:");138 }139 } while (isTrue);140 status[id-1] = true;141 System.out.println("签收完成");142 break;143 case "4":144 System.out.println("****删除订单****");145 System.out.println("请输入要删除的订单编号:");146 int big = length;147 for(int i = 0;i big) {158 System.out.println("不存在此编号菜品,请重新输入:");159 }160 } while (no<1||no>big);161 162 if(status[no-1]==false) {163 System.out.println("订单未完成,不能删除");164 }else {165 for(int i=no-1;i max) {201 System.out.println("不存在此编号菜品,请重新输入:");202 }203 } while (bianhao<1||bianhao>max);204 zan[bianhao-1]++;205 System.out.println("点赞成功,谢谢您的反馈");206 break;207 case "6":208 System.out.println("****退出系统****");209 System.out.println("谢谢使用");210 break;211 212 default:213 System.out.println("选择错误,请重新选择:");214 choose = sc.next();215 break;216 }217 }while(!"6".equals(choose));218 }219 }
基础知识综合运用