1 Star 0 Fork 1

章强/文字迷宫

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
CommandWords.java 1016 Bytes
一键复制 编辑 原始数据 按行查看 历史
章强 提交于 2020-06-21 16:58 . 精灵宝可梦
/**
* 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
{
/**
* 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)
{
Word[] words = Word.values();
for(int i = 0; i < words.length; i++) {
if(words[i].getCommandWord().equals(aString))
return true;
}
// if we get here, the string was not found in the commands
return false;
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/zhangqiang888/labyrinth_of_words.git
git@gitee.com:zhangqiang888/labyrinth_of_words.git
zhangqiang888
labyrinth_of_words
文字迷宫
master

搜索帮助