📄 commandwords.java
字号:
/** * This class holds an enumeration of all command words known * to the program. * * @author Michael Kolling and David J. Barnes * @version 2006.03.30 */public class CommandWords{ // a constant array that holds all valid command words private static final String validCommands[] = { "add", "get", "search", "list", "help", "quit", }; /** * Constructor for CommandWords */ public CommandWords() { } /** * Check whether a given String is a valid command word. * @param aString The string to be checked. * @return true if it is valid, false if it isn't. */ public boolean isCommand(String aString) { if(aString != null){ for(int i = 0; i < validCommands.length; i++) { if(validCommands[i].equals(aString)) return true; } } // if we get here, the string was not found in the commands return false; } /** * Print all valid commands to System.out. */ public void showAll() { for(String command : validCommands) { System.out.print(command + " "); } System.out.println(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -