1 Star 0 Fork 0

韩丽鑫/wordgame

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
CommandWords.java 1.13 KB
一键复制 编辑 原始数据 按行查看 历史
韩丽鑫 提交于 2020-06-20 21:31 . add wordgame.
/**
* 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 = {
"去", "离开", "帮助", "仙女棒", "魔法果",
};
/**
* 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/han_li_xin/wordgame.git
[email protected]:han_li_xin/wordgame.git
han_li_xin
wordgame
wordgame
master

搜索帮助