NOTE: For this question, create all the assets for your solution in a package named quest Name your classes precisely as specified and follow the spec closely. We'll be using some automated tests to validate your code. Assume "good" data; no exception handling is expected or required. We're building an old-school text adventure game. For our first prototype, we need to keep track of Rooms and items for the Game. Create a class called Room. Room instances have names and some collection that allows it to manage/track the items in the room. The "items" are represented as Strings. Your Room class should have a public constructor that matches the following signature: public Room (String name, String [] items) The items argument may be null (meaning the room is empty). Rooms can also give us other information. We can query if a room is empty and/or if a room contains a certain item. Your Room should support the following operations: public boolean isEmpty() public boolean contains(String nameOf Item) We can compare Rooms for equality. In this case, we define rooms as "equal" if the names are the same. Be sure to provide a .equals() override. (Note: You can also provide a hashCode override, but it is not required for this question and no penalty assessed if you do not provide one) public boolean equals(Object other)

CMPTR
3rd Edition
ISBN:9781337681872
Author:PINARD
Publisher:PINARD
Chapter18: Maintaining And Querying A Database
Section: Chapter Questions
Problem 11QY
icon
Related questions
Question

question in java please!

NOTE: For this question, create all the assets for your solution in a package
named quest
Name your classes precisely as specified and follow the spec closely. We'll be
using some automated tests to validate your code. Assume "good" data; no
exception handling is expected or required.
We're building an old-school text adventure game. For our first prototype, we
need to keep track of Rooms and items for the Game.
Create a class called Room. Room instances have names and some collection
that allows it to manage/track the items in the room. The "items" are
represented as Strings. Your Room class should have a public constructor that
matches the following signature:
public Room (String name, String [] items)
The items argument may be null (meaning the room is empty). Rooms can also
give us other information. We can query if a room is empty and/or if a room
contains a certain item. Your Room should support the following operations:
public boolean isEmpty()
public boolean contains (String nameOf Item)
We can compare Rooms for equality. In this case, we define rooms as "equal"
if the names are the same. Be sure to provide a .equals() override. (Note: You
can also provide a hashCode override, but it is not required for this question and
no penalty assessed if you do not provide one)
public boolean equals(Object other)
Transcribed Image Text:NOTE: For this question, create all the assets for your solution in a package named quest Name your classes precisely as specified and follow the spec closely. We'll be using some automated tests to validate your code. Assume "good" data; no exception handling is expected or required. We're building an old-school text adventure game. For our first prototype, we need to keep track of Rooms and items for the Game. Create a class called Room. Room instances have names and some collection that allows it to manage/track the items in the room. The "items" are represented as Strings. Your Room class should have a public constructor that matches the following signature: public Room (String name, String [] items) The items argument may be null (meaning the room is empty). Rooms can also give us other information. We can query if a room is empty and/or if a room contains a certain item. Your Room should support the following operations: public boolean isEmpty() public boolean contains (String nameOf Item) We can compare Rooms for equality. In this case, we define rooms as "equal" if the names are the same. Be sure to provide a .equals() override. (Note: You can also provide a hashCode override, but it is not required for this question and no penalty assessed if you do not provide one) public boolean equals(Object other)
In addition to the Room class, you need to provide a Game class. Game
instances manage collections of Rooms.
Provide a public constructor to create Game instances. Its signature looks like
this:
public Game(List<Room> rooms)
Your Game class should provide two basic methods for filtering and gathering
sub-collections of Rooms based on a given criteria. Here are the signatures
for the methods:
public List<Room> getEmptyRooms ()
public List<Room> getRoomsWith(String item)
getEmptyRooms() returns a List of Rooms from the Game that are empty (e.g.
rooms that answer true when their isEmpty() method is called)
getRoomsWith() returns a List of Rooms from the Game that contain the item
passed in as the parameter
Transcribed Image Text:In addition to the Room class, you need to provide a Game class. Game instances manage collections of Rooms. Provide a public constructor to create Game instances. Its signature looks like this: public Game(List<Room> rooms) Your Game class should provide two basic methods for filtering and gathering sub-collections of Rooms based on a given criteria. Here are the signatures for the methods: public List<Room> getEmptyRooms () public List<Room> getRoomsWith(String item) getEmptyRooms() returns a List of Rooms from the Game that are empty (e.g. rooms that answer true when their isEmpty() method is called) getRoomsWith() returns a List of Rooms from the Game that contain the item passed in as the parameter
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Events
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
CMPTR
CMPTR
Computer Science
ISBN:
9781337681872
Author:
PINARD
Publisher:
Cengage