/* * @topic W020111 Maze: Java application * @brief class Room */ package mazeapp; public class Room { private String name; // constructor public Room(String newName) { name = newName; } // operations public void enter(Visitor visitor) { System.out.println("You entered " + name); for (;;) { // endless loop begins... MazeApp.layout.printWalls(this, visitor); // Ask for an action visitor.askForAction(); // if action is "Go" and direction is East, then let them into the dining room // && is a logical AND operator if (visitor.getLastAction() == 'G' ) { MazeApp.layout.moveVisitor( this, visitor ); // if layout din't take them some place else, then // it must be a bad command } if (visitor.getLastAction() == 'G') { System.out.println("Sorry, bad command!\n"); } }//for }//enter() }//class Room