吃货联盟项目

public class ddddd {
    
        String []name =new String[4];//保存订单人姓名
        String []dishMegs =new String[4];//保存所选信息,包括菜品名及份数
        String []time =new String[4];//保存送餐时间
        String[]address =new String[4];//保存送餐地址
        int[]states =new int[4];//保存订单状态:0表预订.1表示完成
        double []sumPrices =new double[4];//保存订单总金额
    }
import java.util.Scanner;


public class startMenu {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
            Scanner input =new Scanner(System.in);
            int num =-1;//用户输入0返回主菜单,否则推出系统
            boolean isExit =false;//标志是否推出系统,true退出
            System.out.println("欢迎使用“吃货联盟”订餐系统");
            ORderingSet q =new ORderingSet();
            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.println("请选择");
            int choose=input.nextInt();
            
            switch(choose){
            case 1:
                System.out.println("***我要订餐***");
                q.add();
                break;
            case 2:
                System.out.println("***查看餐袋***");
                q.show1();
                break;
            case 3:
                System.out.println("***签收订单***");
                q.sign();
                break;
            case 4:
                System.out.println("***删除订单***");
                q.delete();
                break;
            case 5:
                System.out.println("***我要点赞***");
                q.praise();
                break;
            case 6:
                System.out.println("退出系统");
                isExit=true;
                
                break;
                   
            }if(!isExit){
            System.out.println("输出0返回");
            num=input.nextInt();
            }else{
                break;
            }
            }while(num ==0);
    }
    }
import java.util.Scanner;

public class ORderingSet {

    String[] dishNames = { "红烧带鱼", "鱼香肉丝", "时令蔬菜" };// 菜品名称
    double[] prices = new double[] { 38.0, 20.0, 10.0 };// 菜品价格
    int[] praiseNums = new int[3];// 点赞数
    String[] name = new String[4];// 点餐人姓名
    int[] num = new int[4];// 份数
    String[] address = new String[4];// 地址
    int[] time = new int[4];// 时间
    double[] money = new double[4];// 总金额
    int i = 0;
    int[] praiseNum = new int[4];// 点赞
    int[] states = new int[4];
    ddddd oSet = new ddddd();
    String[] cai = new String[4];// 储存菜品
    int q;
    Scanner input = new Scanner(System.in);
//
    public void initial() {
        Scanner input = new Scanner(System.in);
        System.out.println("序号\t订餐人\t餐品信息\t\t送餐时间\t送餐地址\t\t总金额\t订餐状态");
        for (int i = 0; i <= name.length; i++) {
            if (name[i] != null) {
                String state = (states[i] == 0) ? "已预订" : "已完成";
                String date = time[i] + "点";
                String sumPrice = money[i] + "元";
                System.out.println((i + 1) + "\t" + name[i] + "\t" + cai[i]
                        + "\t" + date + "\t" + address[i] + "\t" + sumPrice
                        + "\t" + state);
            }
        }
    }

    public void add() {
        Scanner input = new Scanner(System.in);
        int ch;
        for (; i < name.length;) {
            System.out.println("请输入订餐姓名");
            name[i] = input.next();
            do {
                System.out.println("序号" + "\t" + "菜名" + "\t" + "单价" + "\t"
                        + "点赞数");
                for (int u = 0; u < dishNames.length; u++) {
                    System.out.println((u + 1) + "\t" + dishNames[u] + "\t"
                            + prices[u] + "\t" + praiseNums[u]);
                }
                System.out.println("请选择你要点的菜品编号");
                ch = input.nextInt();
                if (ch < 1 || ch > 3) {
                    System.out.println("没有此菜品,请重新输入:");
                }
            } while (ch < 1 || ch > 3);
            cai[i] = dishNames[ch - 1];
            System.out.println("请选择你的份数");
            num[i] = input.nextInt();
            System.out.println("请输入送餐时间(时间是10点至12点整点送餐)");
            time[i] = input.nextInt();
            while (time[i] < 10 || time[i] > 20) {
                System.out.println("你输入的有错误.请输入10-20的整数");
                time[i] = input.nextInt();
            }
            System.out.println("请输入送餐地址");
            address[i] = input.next();
            System.out.println("订餐成功");
            System.out.println("你订的是:" + cai[i]);
            System.out.println("订餐时间" + time[i] + "点");
            double mon = 0;
            double mons = num[i] * prices[i];
            if (money[i] < 50) {
                mon = 5;
            }
            System.out.println("订餐费:" + mons + "元.送餐费" + mon + "元,总计:"
                    + (mons + mon) + "元");
            money[i] = mons + mon;
            break;
        }
        if (i >= address.length) {
            System.out.println("菜袋已满!");
        } else {
            i++;
        }
    }

    public void show1() {
        System.out.println("序号\t订餐人\t餐品信息\t\t送餐时间\t送餐地址\t\t总金额\t订餐状态");
        for (int i = 0; i < name.length; i++) {
            if (name[i] != null) {
                String state = (states[i] == 0) ? "已预订" : "已完成";
                String date = time[i] + "点";
                String sumPrice = money[i] + "元";
                System.out.println((i + 1) + "\t" + name[i] + "\t" + cai[i]
                        + "\t" + date + "\t" + address[i] + "\t" + sumPrice
                        + "\t" + state);
                
            }
        }
    }
//签收订单:查看餐带:
    public void sign() {

        boolean isSignFind = false;
        System.out.println("请选择你要签收的订单序号");
        int signOrderId = input.nextInt();
        for (int i = 0; i < name.length; i++) {
            
            if (name[i] != null && states[i] == 0 && signOrderId == i + 1) {
                states[i] = 1;
                System.out.println("订单签收成功!");
                isSignFind = true;
            } else if (name[i] != null && states[i] == 1
                    && signOrderId == i + 1) {
                System.out.println("您的订单已经签收,不可重复签收!");
                isSignFind = true;
            }
        }
        if (!isSignFind) {
            System.out.println("没有此项订单!");
        }
    }
//删除订单:
    public void delete() {
        Scanner input = new Scanner(System.in);
        boolean isDeIfind = false;
        System.out.println("请选择你要删除的订单序号");
        int deIId = input.nextInt();
        for (int i = 0; i < name.length; i++) {
            if (name[i] != null && states[i] == 1 && deIId == i + 1) {
                isDeIfind = true;
                for (int j = deIId - 1; j < name.length - 1; j++) {
                    name[j] = name[j + 1];
                    cai[j] = cai[j + 1];
                    time[j] = time[j + 1];
                    address[j] = address[j + 1];
                    states[j] = states[j + 1];
                    money[j] = money[j + 1];
                }
                int endIndex = name.length - 1;
                name[endIndex] = null;
                cai[endIndex] = null;
                time[endIndex] = 0;
                address[endIndex] = null;
                states[endIndex] = 0;
                money[endIndex] = 0.0;
                System.out.println("删除成功");
                break;
            } else if (name[i] != null && states[i] == 0
                    && deIId == i + 1) {
                System.out.println("你选择的订单没有签收,不能删除");
                isDeIfind = true;
                break;
            }
        }
        if (!isDeIfind) {
            System.out.println("你要删除的订单没有找得到");
        }
    }
//我要点赞:
    public void praise() {
        int a;
        Scanner input = new Scanner(System.in);
        do {
            System.out.println("请选择你要点赞的菜品序号");
            a = input.nextInt();
            switch (a) {
            case 1:
                praiseNum[0]++;
                System.out.println("点赞成功!");
                break;
            case 2:
                praiseNum[1]++;
                System.out.println("点赞成功!");
                break;
            case 3:
                praiseNum[2]++;
                System.out.println("点赞成功!");
                break;
            default:
                System.out.println("没有此菜品,请重新选择:");
                break;
            }
        } while (a > name.length);
    }

 

posted @ 2017-08-21 17:11  秋风伊人  阅读(348)  评论(0编辑  收藏  举报