?? menu.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;
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -