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)
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
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.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F7946b8ad-32cf-4c0f-ab08-4fb9e7e93698%2Fdd5396bf-1a37-4a4a-84e7-7fc6e24a4dc3%2F06nei2kt_processed.png&w=3840&q=75)
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.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F7946b8ad-32cf-4c0f-ab08-4fb9e7e93698%2Fdd5396bf-1a37-4a4a-84e7-7fc6e24a4dc3%2F4oc81tk_processed.png&w=3840&q=75)
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
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Knowledge Booster
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](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
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)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
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)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education