⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 menu.java

📁 数独的一种实现
💻 JAVA
字号:
// Decompiled by DJ v3.9.9.91 Copyright 2005 Atanas Neshkov  Date: 2/13/2008 10:16:23 PM
// Home Page : http://members.fortunecity.com/neshkov/dj.html  - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name:   Menu.java

import java.io.PrintStream;
import java.util.Scanner;

public class Menu
{

    public Menu(int i)
    {
        this(i, new Scanner(System.in));
    }

    public Menu(int i, Scanner scanner)
    {
        choices = new char[i];
        descriptions = new String[i];
        count = 0;
        sc = scanner;
        echo = false;
    }

    public void addItem(char c, String s)
    {
        if(count < choices.length)
        {
            choices[count] = c;
            descriptions[count] = s;
            count++;
        } else
        {
            System.err.println("ERROR!  This Menu object is full.To add more items, you must pass a larger value of pCount to the constructor.\n");
            System.exit(0);
        }
    }

    public char getChoice()
    {
        char c = ' ';
        boolean flag = false;
        do
        {
            if(flag)
                break;
            for(int i = 0; i < count; i++)
                System.out.println((new StringBuilder()).append(choices[i]).append(" - ").append(descriptions[i]).toString());

            System.out.print("Please enter your choice: ");
            String s = sc.nextLine().toUpperCase();
            if(s.length() > 0)
            {
                c = s.charAt(0);
                if(echo)
                    System.out.println(c);
                for(int j = 0; j < count; j++)
                    if(c == choices[j])
                        flag = true;

            }
            if(!flag)
                System.out.println("Invalid choice, please try again.");
        } while(true);
        return c;
    }

    public void setEcho(boolean flag)
    {
        echo = flag;
    }

    public double getVersion()
    {
        return 2.3999999999999999D;
    }

    char choices[];
    String descriptions[];
    int count;
    Scanner sc;
    boolean echo;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -