吃货联盟订餐系统

package cn.jbit.classandobject;

public class Biye {
      String[] name=new String[4];//订餐人姓名
      String[] dish=new String[4];//所选菜品
      int[] time=new int[4];//送餐时间
      String[] add=new String[4];//送餐地址
      int[] states=new int[4];//订餐状态:0.已预订1.已完成
      double[] sum=new double[4];//总金额
}

package cn.jbit.classandobject;
import java.util.*;
public class Biye2 {
        String[] cainame={"鱼香肉丝","红烧带鱼","时令鲜蔬"};
        double[] caimoney={ 38.0, 20.0, 10.0 }; 
        int[] zang=new int[3];
        Scanner input=new Scanner(System.in);
        Biye shuzu=new Biye();
        public void initial(){			
        	shuzu.name[0] = "张晴";
        	shuzu.dish[0] = "红烧带鱼 2份";
        	shuzu.time[0] = 12;
        	shuzu.add[0] = "天成路207号";
        	shuzu.sum[0] = 76.0;
        	shuzu.states[0] = 1;
        	shuzu.name[1] = "张晴";
        	shuzu.dish[1] = "鱼香肉丝 2份";
        	shuzu.time[1] = 18;
        	shuzu.add[1] = "天成路207号";
        	shuzu.sum[1] = 20.0;
        	shuzu.states[1] = 0;
    	}
        boolean ding(){
        	boolean isci=false;
        	for (int i = 0; i <shuzu.name.length; i++) {
				if(shuzu.name[i]==null){
					isci=true;
					System.out.println("请输入您的姓名:");
					String name=input.next();
					System.out.println("序号" + "\t" + "菜名" + "\t" + "单价" + "\t" + "点赞数");
					for (int j = 0; j < cainame.length; j++) {
						String yuan=caimoney[j]+"元";
						String dian=(zang[j])>0?zang[i]+"赞":"0";
						System.out.println((j + 1) + "\t" + cainame[j] + "\t"+yuan+"\t"+ dian);
					}
					System.out.println("请输入您选择的菜品编号:");
					int cai=input.nextInt();
					System.out.println("请输入您需要的份数:");
					int fen=input.nextInt();
					double qian=caimoney[cai-1]*fen;
					String meg=cainame[cai-1]+""+fen+"份";
					double fei=0.0;
					if(fei<50){
						fei=5;
					}else{
						fei=0;
					}
						System.out.print("请输入送餐时间(送餐时间是10点至20点间整点送餐):");
						int time = input.nextInt();
						while (time < 10 || time > 20) {
							System.out.print("您的输入有误,请输入10~20间的整数!");
							time = input.nextInt();
						}
							System.out.print("请输入送餐地址:");
							String address = input.next();
							System.out.println("订餐成功!");
							System.out.println("您订的是:"+meg);
							System.out.println("送餐时间:"+time+"时");
							System.out.println("餐费:"+qian+"元,送餐费"+fei+"元,总计:"+(qian+fei)+"元。");
							shuzu.name[i] = name;
							shuzu.dish[i] = cainame[cai-1];
							shuzu.time[i] = time;
							shuzu.add[i] = address;
							shuzu.sum[i] = qian+fei;					
							break;
					}
        }
        	if(!isci){
				System.out.println("您的餐袋已满");
				return false;
			}else{
				return true;
			}
       
}
        void cip(){
        	System.out.println("序号\t订餐人\t餐品信息\t\t送餐时间\t送餐地址\t\t总金额\t订单状态");
        	for (int i = 0; i < shuzu.name.length; i++) {
				if(shuzu.name[i]!=null){
					String state = (shuzu.states[i]==0)?"已预定":"已完成";
					String date = shuzu.time[i]+"时";
					String sumPrice = shuzu.sum[i]+"元";
					System.out.println((i+1)+"\t"+shuzu.name[i] + "\t"+ "\t"+shuzu.dish[i]+"\t"+date+"\t"+ shuzu.add[i]+"\t"+sumPrice+"\t"+state);
				}
			}
        }
         void yic(){
        	boolean unjun=false;
        	System.out.print("请选择要签收的订单序号:");
    		int sig = input.nextInt();
    		for (int i = 0; i < shuzu.name.length; i++) {
    			if(shuzu.name[i]!=null && shuzu.states[i]==0 && sig==i+1){
    				shuzu.states[i] = 1; 
    				System.out.println("订单签收成功!");
    				unjun = true;
    			}else if(shuzu.name[i]!=null && shuzu.states[i]==1 && sig==i+1){
    				System.out.println("您选择的订单已完成签收,不能再次签收!");
    				unjun = true;
    			}
    		}
    		if(!unjun){
    			System.out.println("您选择的订单不存在!");
    		}
    	}
        void jian(){
        	boolean chun=false;
        	System.out.println("请输入您要查询的订单序号:");
        	int xu=input. nextInt();
        	for (int i = 0; i < shuzu.name.length; i++) {
        		if(shuzu.name[i]!=null && shuzu.states[i]==1 && xu==i+1){
        			chun = true;
    				for(int j=xu-1;j<shuzu.name.length-1;j++){
    					shuzu.name[j] = shuzu.name[j+1];
    					shuzu.dish[j] = shuzu.dish[j+1];
    					shuzu.time[j] = shuzu.time[j+1];
    					shuzu.add[j] = shuzu.add[j+1];
    					shuzu.states[j] = shuzu.states[j+1];
    				}
    				int nu = shuzu.name.length-1;
    				shuzu.name[nu] = null;
    				shuzu.dish[nu] = null;
    				shuzu.time[nu] = 0;
    				shuzu.add[nu] = null;
    				shuzu.states[nu] = 0;
    				
    				System.out.println("删除订单成功!");
    				break;
    			}else if(shuzu.name[i]!=null && shuzu.states[i]==0 && xu==i+1){
    				System.out.println("您选择的订单未签收,不能删除!");
    				chun = true;
    				break;
    			}
    		}
    		if(!chun){
    			System.out.println("您要删除的订单不存在!");
    		}
    	}
        void ping(){
    		System.out.println("序号" + "\t" + "菜名" + "\t" + "单价" + "\t" + "点赞数");
    		for (int i = 0; i < cainame.length; i++) {
    			String price = caimoney[i] + "元";
    			String zhang;
    			if (zang[i] > 0 )
    				zhang = zang[i] + "赞";
    			else
    				zhang = "";
    			
    			System.out.println((i + 1) + "\t" + cainame[i] + "\t"	+price+"\t"+ zhang);
    		}
    		int priaiseNum;
    		do {
    			System.out.print("请选择您要点赞的菜品序号:");
    			priaiseNum = input.nextInt();
    		}while (priaiseNum<=0 || priaiseNum>cainame.length);
    		zang[priaiseNum-1]++;
    		System.out.println("点赞成功!");
    	}
        public void niu(){
        	int num=-1;
        	boolean isc=false;
        	System.out.println("欢迎使用吃货联盟订餐系统");
        	do{
        		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.print("请选择:");
    			int oose = input.nextInt();
    			switch (oose) {
				case 1:
					System.out.println("***我要订餐***");
					ding();
					break;
                case 2:
                	System.out.println("***查看餐袋***");
                	cip();
					break;
                case 3:
                	System.out.println("***签收订单***");
                	yic();
 					break;
                case 4:
                	System.out.println("***删除订单***");
                	jian();
 					break;
                case 5:
                	System.out.println("***我要点赞***");
                	ping();
 					break;
                case 6:
                	isc = true;
    				break;
				default:
					isc = true;
					break;
				}
    			if (!isc) {
    				System.out.print("输入0返回:");
    				num = input.nextInt();
    			} else {
    				break;
    			}
        	}while(num==0);
        	System.out.println("谢谢使用,欢迎下次光临!");
        }
    }
package cn.jbit.classandobject;

public class BiyeMax {
	public static void main(String[] args) {
		
	
     Biye2 hah=new Biye2();
     hah.initial();
     hah.niu();
	}
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值