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)

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

question in java please!

**Building a Text Adventure Game in Java**

**Package Setup:**
- Create a package named `quest`.

**Class Naming and Structure:**
- Follow precise naming conventions and specifications.
- Use automated tests to validate the code.
- Assume data is "good"; no need for exception handling.

**Prototype Development:**
- Focus: Create a ‘Room’ to track Rooms and items within the game.

**Class Creation:**
- Create a class called `Room`.

**Room Class Details:**

1. **Constructor:**
   ```java
   public Room(String name, String [] items)
   ```
   - **Parameters:**
     - `name`: The name of the room.
     - `items`: A collection of items (Strings) in the room.
   - The `items` parameter can be `null`, indicating an empty room.

2. **Operations:**
   - **Check if Room is Empty:**
     ```java
     public boolean isEmpty()
     ```
   - **Check if Room Contains an Item:**
     ```java
     public boolean contains(String nameOfItem)
     ```

3. **Comparing Rooms:**
   - Define rooms as "equal" if their names are the same.
   - Implement an override for `.equals()` method:
     ```java
     public boolean equals(Object other)
     ```
     - Note: Providing a `hashCode` override is optional.

By setting up and implementing these components, you’ll lay a solid foundation for expanding on the text adventure game.
Transcribed Image Text:**Building a Text Adventure Game in Java** **Package Setup:** - Create a package named `quest`. **Class Naming and Structure:** - Follow precise naming conventions and specifications. - Use automated tests to validate the code. - Assume data is "good"; no need for exception handling. **Prototype Development:** - Focus: Create a ‘Room’ to track Rooms and items within the game. **Class Creation:** - Create a class called `Room`. **Room Class Details:** 1. **Constructor:** ```java public Room(String name, String [] items) ``` - **Parameters:** - `name`: The name of the room. - `items`: A collection of items (Strings) in the room. - The `items` parameter can be `null`, indicating an empty room. 2. **Operations:** - **Check if Room is Empty:** ```java public boolean isEmpty() ``` - **Check if Room Contains an Item:** ```java public boolean contains(String nameOfItem) ``` 3. **Comparing Rooms:** - Define rooms as "equal" if their names are the same. - Implement an override for `.equals()` method: ```java public boolean equals(Object other) ``` - Note: Providing a `hashCode` override is optional. By setting up and implementing these components, you’ll lay a solid foundation for expanding on the text adventure game.
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:

```java
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:

```java
public List<Room> getEmptyRooms()
```

```java
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: ```java 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: ```java public List<Room> getEmptyRooms() ``` ```java 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.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education