吃货联盟系统代码
代码如下(示例)
吃货联盟系统代码
import java. util. Scanner;
public class chihuolianmengfupan {
public static void main ( String[ ] args) {
Scanner s= new Scanner ( System. in) ;
int chose;
String [ ] cai= { "狮子头" , "回锅肉" , "酸辣粉" , "红烧肉" } ;
int [ ] jia= { 45 , 35 , 25 , 35 } ;
String[ ] [ ] able= new String[ 1000 ] [ 3 ] ;
int [ ] zan= new int [ 4 ] ;
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 ( "请您输入您要选择的项目:" ) ;
chose= s. nextInt ( ) ;
switch ( chose) {
case 1 :
System. out. println ( "***********我要点餐*********" ) ;
System. out. println ( "根据餐费列表点餐" ) ;
System. out. println ( "序号\t菜名\t价格\t点赞数" ) ;
for ( int i= 0 ; i< cai. length; i++ ) {
System. out. println ( i+ 1 + "\t" + cai[ i] + "\t" + jia[ i] + "元" + "\t" + zan[ i] ) ;
}
System. out. println ( "请输入对应菜品序号:" ) ;
int code= s. nextInt ( ) ;
System. out. println ( "请选择份数:" ) ;
int fen= s. nextInt ( ) ;
System. out. println ( "请选择送餐地址:" ) ;
String dress= s. next ( ) ;
System. out. println ( "请输入您的姓名" ) ;
String name= s. next ( ) ;
int time;
do {
System. out. println ( "请输入送餐时间10~20点期间:" ) ;
time= s. nextInt ( ) ;
if ( time< 10 || time> 20 ) {
System. out. println ( "对不起不在服务时间内,请重新输入" ) ;
}
} while ( time< 10 || time> 20 ) ;
int sum= jia[ code- 1 ] * fen;
sum= sum> 50 ? sum: sum+ 6 ;
System. out. println ( "尊敬的" + name+ "您好,您的订单是" + fen+ "份" + cai[ code- 1 ]
+ "价格是" + sum+ "元" + "送餐地址是" + dress+ "送餐时间" + time) ;
for ( int i= 0 ; i< able. length; i++ ) {
if ( able[ i] [ 1 ] == null) {
able[ i] [ 0 ] = cai[ code- 1 ] + "\t" + fen+ "\t" + sum+ "\t" + name+ "\t" + dress+ "\t" + time;
able[ i] [ 1 ] = "已预定" ;
break ;
}
if ( i== able. length- 1 ) {
System. out. println ( "订单已满,无法预定" ) ;
}
}
System. out. println ( "***********输入7返回主菜单*********" ) ;
int num= s. nextInt ( ) ;
break ;
case 2 :
System. out. println ( "**********查看订单**********" ) ;
System. out. println ( "序号\t菜名\t份数\t总价\t姓名\t地址\t时间\t状态" ) ;
for ( int i= 0 ; i< able. length; i++ ) {
if ( able[ i] [ 0 ] == null) {
break ;
}
System. out. println ( i+ 1 + "\t" + able[ i] [ 0 ] + "\t" + able[ i] [ 1 ] ) ;
}
System. out. println ( "***********输入7返回主菜单*********" ) ;
num= s. nextInt ( ) ;
break ;
case 3 :
System. out. println ( "***********确认订单*********" ) ;
System. out. println ( "序号\t菜名\t份数\t总价\t姓名\t地址\t时间\t状态" ) ;
for ( int i= 0 ; i< able. length; i++ ) {
if ( able[ i] [ 0 ] == null) {
break ;
}
System. out. println ( i+ 1 + "\t" + able[ i] [ 0 ] + "\t" + able[ i] [ 1 ] ) ;
}
System. out. println ( "请输入要确定的订单编号" ) ;
int ell= s. nextInt ( ) ;
if ( able[ ell- 1 ] [ 1 ] == null) {
System. out. println ( "订单不存在,无法签收" ) ;
} else if ( able[ ell- 1 ] [ 1 ] . equals ( "已完成" ) ) {
System. out. println ( "该订单已签收,不能重复签收" ) ;
} else {
able[ ell- 1 ] [ 1 ] = "已完成" ;
System. out. println ( "签收成功" ) ;
}
System. out. println ( "***********输入7返回主菜单*********" ) ;
num= s. nextInt ( ) ;
break ;
case 4 :
System. out. println ( "***********删除订单*********" ) ;
System. out. println ( "序号\t菜名\t份数\t总价\t姓名\t地址\t时间\t状态" ) ;
for ( int i= 0 ; i< able. length; i++ ) {
if ( able[ i] [ 0 ] == null) {
break ;
}
System. out. println ( i+ 1 + "\t" + able[ i] [ 0 ] + "\t" + able[ i] [ 1 ] ) ;
}
System. out. println ( "请输入要删除的订单编号" ) ;
int del= s. nextInt ( ) ;
if ( del< 1 || del> 1000 ) {
System. out. println ( "输入错误!" ) ;
} else if ( able[ del- 1 ] [ 1 ] == null) {
System. out. println ( "订单不存在!" ) ;
} else if ( ! able[ del- 1 ] [ 1 ] . equals ( "已完成" ) ) {
System. out. println ( "未完成订单,不能删除" ) ;
} else {
for ( int i = del; i< able. length; i++ ) {
able[ i- 1 ] = able[ i] ;
if ( able[ i] [ 1 ] == null) {
break ;
}
}
}
System. out. println ( "删除成功" ) ;
System. out. println ( "***********输入7返回主菜单*********" ) ;
num= s. nextInt ( ) ;
break ;
case 5 :
System. out. println ( "***********我要点赞*********" ) ;
System. out. println ( "序号\t菜名\t价格\t点赞数" ) ;
for ( int i= 0 ; i< cai. length; i++ ) {
System. out. println ( i+ 1 + "\t" + cai[ i] + "\t" + jia[ i] + "元" + zan[ i] ) ;
}
System. out. println ( "请输入您要点赞的菜品" ) ;
int za= s. nextInt ( ) ;
if ( za< 1 || za> zan. length) {
System. out. println ( "输入有误!" ) ;
} else {
zan[ za- 1 ] ++ ;
System. out. println ( cai[ za- 1 ] + "点赞成功" + "赞数" + zan[ za- 1 ] ++ ) ;
}
System. out. println ( "***********输入7返回主菜单*********" ) ;
num= s. nextInt ( ) ;
break ;
case 6 :
System. out. println ( "***********退出系统*********" ) ;
break ;
default :
break ;
}
} while ( chose!= 0 ) ;
System. out. println ( "谢谢惠顾,欢迎下次光临!" ) ;
}
}