How should the information be produced about an item present in a room?

Question:

How should the information be produced about an item present in a room? Which class should produce the string describing the item? Which class should print it? Why? Explain in writing. If answering this exercise makes you feel you should change your implementation, go ahead and make the changes.

Answer:

Step: 1 of 2

Item and game Class

The items are present in the rooms. When the player enters the room, then the room should produce the information about an item present in a room.

The Item class can produce the string describing the information of the item.

Step: 2 of 2

The game class is responsible for printing and hence should also print the description of item information. It is, however, not needed to clearly print the item described in the game class, if the description of the room includes the information of the item in the room. Because we are printing the room details in the Game class method only.

Leave a Comment

Your email address will not be published. Required fields are marked *