1 Star 0 Fork 122

天寒/zuul

forked from 吕焱飞/zuul 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
CommandWords.java 1.10 KB
一键复制 编辑 原始数据 按行查看 历史
luyanfei78 提交于 2020-05-06 08:43 . initial commit.
/**
* 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
private static final String[] validCommands = {
"go", "quit", "help"
};
/**
* Constructor - initialise the command words.
*/
public CommandWords()
{
// nothing to do at the moment...
}
/**
* 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)
{
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;
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/qianwensheng12138/zuul.git
git@gitee.com:qianwensheng12138/zuul.git
qianwensheng12138
zuul
zuul
master

搜索帮助