java基础思维导图
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/41d6cb29c0bc47399e02730c9337526f.png)
项目实战
##吃货联盟订餐系统
数据主体:
1. 我要订餐:姓名,菜品(提前预置),份数,时间(10-20点)
case 1:
System.out.println("***我要订餐***");
System.out.print("请输入订餐人姓名");
name=sc.next();
System.out.println("序号\t菜品\t单价");
for (int i = 0; i < dishes.length; i++) {
System.out.println(i+1+"\t"+dishes[i]+"\t"+prices[i]+"元");
}
do{
System.out.println("请输入您要点的菜品编号:");
choseNum=sc.nextInt();
if(choseNum>0&&choseNum<=dishes.length){
break;
}
System.out.println("您输入有误,重新输入!");
}while(true);
do{
System.out.println("请选择您需要的份数:");
pcs=sc.nextInt();
if(pcs>0)break;
System.out.println("份数不能小于0,重新输入");
}while(true);
do{
System.out.println("请输入送餐时间(10点至20点整点送餐):");
time=sc.nextInt();
if(time>=10&&time<=20)break;
System.out.println("输入有误");
}while(true);
System.out.println("请输入送餐地址:");
address=sc.next();
System.out.println("订餐成功!");
System.out.println("您订的是:"+dishes[choseNum-1]);
System.out.println("送餐时间:"+time+"点");
double dishPrice=prices[choseNum-1]*pcs;
int sendMoney=0;
if(dishPrice<NO_SEND_MONEY){
sendMoney=6;
}double totalPrics=dishPrice+sendMoney;
System.out.println("餐费:"+dishPrice+"元,送餐费"+sendMoney+"元,"+"总计:"+totalPrics);
//插入订单,遍历订单,如果为空,则插入
for (int i = 0; i < bills.length; i++) {
if(bills[i]==null){
bills[i]=new String[6];
bills[i][0]=name;
bills[i][1]=dishes[choseNum-1]+" "+pcs+"份";
bills[i][2]=time+"点";
bills[i][3]=address;
bills[i][4]=totalPrics+"元";
bills[i][5]="已预定";
break;
}
}
System.out.print("输入0返回:");
choose=sc.nextInt();
break;
- 查看餐袋(订单):编号,订餐人,菜品名,份数,总价,时间,地址,状态
case 2:
System.out.println("***查看订单***");
System.out.println("序号\t订餐人\t餐品信息\t送餐日期\t送餐地址\t总金额\t订单状态");
for ( int i = 0; i < bills.length; i++) {
if(bills[i]==null){
break;
}
System.out.println(i+1+"\t"+bills[i][0]+"\t"+bills[i][1]+"\t"+bills[i][2]+"\t"+bills[i][3]+"\t"+bills[i][4]+"\t"+bills[i][5]);
}
System.out.print("输入0返回:");
choose=sc.nextInt();
break;
3.签收订单
case 3:
System.out.println("***签收订单***");
if(bills[0]==null){
System.out.println("订单为空,不可签收");
System.out.println("输入0返回");
choose=sc.nextInt();
break;
}
System.out.println("序号\t订餐人\t餐品信息\t总金额\t订单状态");
int i = 0;
for (; i < bills.length; i++) {
if(bills[i]==null){
break;
}
System.out.println(i+1+"\t"+bills[i][0]+"\t"+bills[i][1]+"\t"+bills[i][4]+"\t"+bills[i][5]);
}
int signNUm;
do{
System.out.println("编号");
signNUm=sc.nextInt();
if(signNUm>0&&signNUm<=i)break;;
System.out.println("订单不存在,请重新输入");
}while(true);
if(bills[signNUm-1].equals("已完成")){
System.out.println("订单已经完成签收,不需要重复签收");
}else
bills[signNUm-1][5]="已完成";
// System.out.println("选择要签收的订单编号");
// int signNum=sc.nextInt();
System.out.print("输入0返回:");
choose=sc.nextInt();
break;
4.删除订单
case 4:
System.out.println("***删除订单***");
if(bills[0]==null){
System.out.println("订单为空,不可删除");
System.out.println("输入0返回");
choose=sc.nextInt();
break;
}
System.out.println("序号\t订餐人\t餐品信息\t总金额\t订单状态");
int k = 0;
for (; k < bills.length; k++) {
if(bills[k]==null){
break;
}
System.out.println(k+1+"\t"+bills[k][0]+"\t"+bills[k][1]+"\t"+bills[k][4]+"\t"+bills[k][5]);
}
int delNUm;
do{
System.out.println("请输入要删除订单的编号");
delNUm=sc.nextInt();
if(bills[0]==null)break;
if(delNUm>0&&delNUm<=k){
}
System.out.println("订单不存在,请重新输入");
}while(true);
//未完成的订单不能删除
//删除订单需要考虑选择的删除后,后面的订单需要前移
if(!bills[delNUm-1][5].equals("已完成"))
System.out.println("未完成的订单不能删除!");
else{
for(int s=delNUm-1;bills[s]!=null;s++){
if(delNUm==bills.length){
bills[delNUm-1]=null;
}else{
bills[s]=bills[s+1];
}
}
System.out.println("删除完成!");
}
System.out.print("输入0返回:");
choose=sc.nextInt();
break
5.我要点赞
case 5:
System.out.println("***我要点赞***");
System.out.println("序号\t菜品\t单价\t点赞数");
for (int j= 0; j < dishes.length;j++) {
System.out.println(j+1+"\t"+dishes[j]+"\t"+prices[j]+"元"+"\t"+like[j]);
}int likeNum;
do{
System.out.println("请选择点赞的菜品");
likeNum=sc.nextInt();
if(likeNum>0&&likeNum<=like.length)break;
System.out.println("没有这个菜品,请重新输入");
}while (true);
like[likeNum-1]++;
System.out.println("谢谢点赞!");
System.out.print("输入0返回:");
choose=sc.nextInt();
break;