您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

选择选项后如何向用户显示我再次创建的菜单-Java

选择选项后如何向用户显示我再次创建的菜单-Java

为了使客户端菜单在完成后返回登录菜单,请添加两个while循环,一个用于登录屏幕,一个用于客户端屏幕,如下所示:

boolean loginScreenDone=false;

while(!loginScreenDone) {
    System.out.println("--------Login Screen--------");

    System.out.println("Enter C for client and E for employee: ");

    String login = s.nextLine();


    if ("C".equals(login)) {
        boolean clientScreenDone=false;

        while(!clientScreenDone) {
            System.out.println("Welcome to the client screen");
            System.out
                .println("There are 3 Lotteries (Lotto, Jackpot and National)");
            System.out.println("Please select one (L, J, N) or E to exit: ");
            String select = s.nextLine();

            switch (select) {
            case "L":
                //call a method to handle Lotto here
                break;
            case "J":
                //call a method to handle Jackpot here
                break;
            case "N":
                //call a method to handle National here
                break;
            case "E":
                clientScreenDone=true;
                break;
            default:
                System.out.println("Invalid Selection");
                break;
        }
    }
}
java 2022/1/1 18:27:09 有481人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶