SYSC 2004 Lecture Notes - Lecture 3: Interactive Fiction
Document Summary
* 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 kolling and david j. barnes. * @version october 21, 2012 public class commandwords. // a constant array that holds all valid command words private static final string[] validcommands = { "go", "quit", "help" , "look" , "eat" ,"back" ,"stackback" * constructor - initialise the command words. public commandwords() * check whether a given string is a valid command word. * @return true if it is valid, false otherwise 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;