Java程序题目1:生成作业管理系统

        在查看章节案例1——搭建javahomeWork项目视频后,在自己的开发环境上完成作业项目的搭建。

实现以下功能。

交互界面可以多次重复选择作业章节号,进入对应的作业章节。如下图所示:

实现效果如下:(目录效果可以按照个人喜好进行更改,这里仅提供笔者个人设计方案)

package edu.java.homework.chapter;

import java.util.Scanner;

public class Menu {
    public static final String ANSI_RESET = "\u001B[0m";
    public static final String ANSI_RED = "\u001B[31m";
    //设置字体颜色

    public void showMenu(){
        while(true){
            clearScreen();
            //设置清屏函数
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            //设定缓冲时间,可删去
            System.out.println("欢迎登陆Java程序查询系统,请选择您要查询的程序:");
            System.out.println("程序Ⅰ--------1");
            System.out.println("程序Ⅱ--------2");
            System.out.println("程序Ⅲ--------3");
            System.out.println("程序Ⅳ--------4");
            System.out.println("输入程序代号(0:退出):");
            Scanner reader=new Scanner(System.in);
            int option=reader.nextInt();
            if(option==1){
                System.out.println("Loading……");
                Chapter1 chapter1=new Chapter1();
                chapter1.chapterMenu();
            }else if(option==2){
                System.out.println("Loading……");
                Chapter2 chapter2=new Chapter2();
                chapter2.chapterMenu();
            }else if(option==3){
                System.out.println("Loading……");
                System.out.println("Display the title of the ChapterThree");
            }else if(option==4){
                System.out.println("Loading……");
                System.out.println("Display the title of the ChapterFour");
            }else if(option==0){
                System.out.println("感谢您的使用,期待您的下次访问!");
                break;
            }else{
                System.out.println(ANSI_RED + "Warning! \nError type: Input error\nPlease enter the correct operation code!" + ANSI_RESET);
            }
               //更改字体颜色的显示方法
        }
    }

    public static void clearScreen() {
        System.out.print("\033[H\033[2J");
        System.out.flush();
    }
}

设置好主目录后,设置主类和主方法:
 

package edu.java.homework.main;
import edu.java.homework.chapter.Menu;

public class Main {

    public static void main(String[] args){
        Menu menu=new Menu();
        menu.showMenu();
    }
}

后续的作业系统将基于此进行添加。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

白苏文

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值