in this Application, you refactor and extend the world-of-zuul game that you beg
ID: 3528944 • Letter: I
Question
in this Application, you refactor and extend the world-of-zuul game that you began exploring in the previous Application for this unit. Perform the activities in each of the numbered steps. You may have already completed steps that are related to exercises in the book; you will see the exercise numbers listed for reference. Note: The necessary files come as part of the packaged filed included with the CD and/or are downloadable from the book's website for free. 1. Open the original project zuul-better that you first encounter in this unitExplanation / Answer
import java.util.HashMap; import java.util.Iterator; /** * 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 2008.03.30 */ public class CommandWords { // A mapping between a command word and the CommandWord // associated with it. private HashMap commands; /** * Constructor - initialise the command words. */ public CommandWords() { commands = new HashMap(); commands.put("go", new GoCommand()); commands.put("help", new HelpCommand(this)); commands.put("quit", new QuitCommand()); commands.put("take", new TakeCommand()); commands.put("use", new UseCommand()); commands.put("beamer", new BeamerCommand()); } /** * Given a command word, find and return the matching command object. * Return null if there is no command with this name. */ public Command get(String word) { return (Command)commands.get(word); } /** * Print all valid commands to System.out. */ public void showAll() { for(Iterator i = commands.keySet().iterator(); i.hasNext(); ) { System.out.print(i.next() + " "); } System.out.println();
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.