001 /** 002 * Implementation of the 'go' user command. 003 * 004 * @author Michael Kolling and David J. Barnes 005 * @version 2011.07.31 006 */ 007 public class GoCommand extends Command 008 { 009 /** 010 * Constructor for objects of class GoCommand 011 */ 012 public GoCommand() 013 { 014 } 015 016 /** 017 * Try to go to one direction. If there is an exit, enter the new 018 * room, otherwise print an error message. Returns always 'false'. 019 */ 020 public boolean execute(Player player) 021 { 022 if(hasSecondWord()) { 023 String direction = getSecondWord(); 024 player.walk(direction); 025 } 026 else { 027 // if there is no second word, we don't know where to go... 028 System.out.println("Go where?"); 029 } 030 return false; 031 } 032 }