Ejemplo n.º 1
0
        public void DoorTest()
        {
            Room r1 = new Room(1);
            Room r2 = new Room(2);
            Door door = new Door(r1, r2);

            Room result = door.OtherSideFrom(r1);

            Assert.AreSame(result, r2);
        }
Ejemplo n.º 2
0
        public Room OtherSideFrom(Room room)
        {
            if (!(room == _roomA || room == _roomB))
            {
                throw new System.ArgumentException("Parameter must be connected to door", "room");
            }

            if (room == _roomA)
            {
                return _roomB;
            }
            else
            {
                return _roomA;
            }
        }
Ejemplo n.º 3
0
 public Maze CreateMaze()
 {
     Maze maze = new Maze();
     Room r1 = new Room(1);
     Room r2 = new Room(2);
     Door theDoor = new Door(r1, r2);
     maze.AddRoom(r1);
     maze.AddRoom(r2);
     r1.SetSide(Direction.North, new Wall());
     r1.SetSide(Direction.East, theDoor);
     r1.SetSide(Direction.South, new Wall());
     r1.SetSide(Direction.West, new Wall());
     r2.SetSide(Direction.North, new Wall());
     r2.SetSide(Direction.East, new Wall());
     r2.SetSide(Direction.South, new Wall());
     r2.SetSide(Direction.West, theDoor);
     return maze;
 }
Ejemplo n.º 4
0
 public Door(Room roomA, Room roomB)
 {
     _roomA = roomA;
     _roomB = roomB;
 }
Ejemplo n.º 5
0
 public void AddRoom(Room room)
 {
     _rooms[room.RoomNumber] = room;
 }