1 Star 0 Fork 122

御子柴/zuul

forked from 吕焱飞/zuul 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
CommandWords.java 1.63 KB
一键复制 编辑 原始数据 按行查看 历史
root 提交于 2021-06-20 17:33 . updated
/**
* This class is part of the "World of Zuul" application.
* "World of Zuul" is a very simple, text based adventure game.
*
* This class holds an enumeration of all command words known to the game.
* It is used to recognise commands as they are typed in.
*
* @author Michael Kölling and David J. Barnes
* @version 2016.02.29
*/
public class CommandWords
{
// a constant array that holds all valid command words
/**
* Constructor - initialise the command words.S
*/
public CommandWords()
{
// nothing to do at the moment...
}
public static String getAllWords(String aString){
CommandWord[] validCommands = CommandWord.values();
String result=" ";
for(int i=0;i<validCommands.length;i++){
result += validCommands[i].isSameWord(aString)+ " ";
}
return result;
}
/**
* Check whether a given String is a valid command word.
* @return true if a given string is a valid command,
* false if it isn't.
*/
public boolean isCommand(String aString)
{
CommandWord[] validCommands = CommandWord.values();
for(int i = 0; i < validCommands.length; i++) {
if(validCommands[i].isSameWord(aString))
return true;
}
// if we get here, the string was not found in the commands
return false;
}
public static String allCommandWords(){
CommandWord[] words = CommandWord.values();
String result= "";
for(CommandWord w: words){
result += w.getCommandWord() + " ";
}
return result;
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/YoMiKa/zuul.git
git@gitee.com:YoMiKa/zuul.git
YoMiKa
zuul
zuul
master

搜索帮助