Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Complete Exercise 6e: 8.4 / 5e: 6.4. Create a map of your game scenario in any common electronic format (such as .pdf, .doc, .pptx, .jpg,

image text in transcribed

  1. Complete Exercise 6e: 8.4 / 5e: 6.4.
    • Create a map of your game scenario in any common electronic format (such as .pdf, .doc, .pptx, .jpg, etc.).
    • Update the source code of your zuul project to create the rooms and connections as you designed them.
    • Update the welcome and help messages to match your scenario.
    • The rooms created in your zuul project and the connections from one room to another should match your map.
      • Make sure the connections between rooms are clear in your map. I will assume that connections between rooms are bidirectional unless you indicate otherwise (e.g., with arrowheads).
  2. Test your program.
  3. Document your changes.
    • Adjust the comment block at the top of the file to include a 1-2 sentence description of your specific game scenario.
    • Add your name to the @author list and update the version.

Java programming

public class Room Code 8.4 Using an accessor method to decrease coupling private String description; private Room northExit; private Room southExit; private Room eastExit; private Room westExit; Existing methods unchanged. public Room getExit(String direction) if(direction.equals("north")) { return northExit; if(direction.equals("east")) { return eastExit; if(direction.equals("south")) { return southExit; } if(direction.equals("west")) { return westExit; return null; Having made this change to the Room class, we need to change the Game class as well. Wherever an exit variable was accessed, we now use the accessor method. For example, instead of writing nextRoom = current Room. east Exit; we now write next Room = current Room.getExit ("east"); This makes coding one section in the Game class much easier as well. In the go Room method, the replacement suggested here will result in the following code segment: Room next Room = null; if(direction.equals("north")) { nextRoom = current Room.getExit("north"): if(direction.equals("east")) { nextRoom = current Room.getExit("east"); if(direction.equals("south")) { nextRoom = currentRoom.getExit("south"); 296 Chapter 8 Designing Classes if(direction.equals("west")) { nextRoom = currentRoom.getExit("west"); Instead, this whole code segment can now be replaced with: Room next Room = currentRoom.getExit(direction)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Objects And Databases International Symposium Sophia Antipolis France June 13 2000 Revised Papers Lncs 1944

Authors: Klaus R. Dittrich ,Giovanna Guerrini ,Isabella Merlo ,Marta Oliva ,M. Elena Rodriguez

2001st Edition

3540416641, 978-3540416647

More Books

Students also viewed these Databases questions

Question

1. What are the peculiarities of viruses ?

Answered: 1 week ago

Question

Describe the menstrual cycle in a woman.

Answered: 1 week ago