Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is a Java project 1. Your project has six classes and two packages, which have already been created. The fixtures package contains the abstract

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

This is a Java project

1. Your project has six classes and two packages, which have already been created. The fixtures package contains the abstract Fixture class that will be used as a base for anything that can be looked at or interacted with. This class should define (at least) the following properties: String name : a short name/ title for the fixture String description : a paragraph-long description of the thing, displayed when the player investigates the fixture thoroughly (looks at it, or enters a room) Make sure to give the Fixture class a constructor that takes in three String parameters and initializes the name and description instance variables. Create your getters and setters as well. 2. The fixtures package also contains the Room class. This class represents a room in the house. It will extend the Fixture class, and so will inherit the descriptive properties. The Room will also have the following property: Room [] exits : an array of the rooms adjacent to this one. You might decide that a room in a particular direction always uses a certain index, e.g. a north exit always goes in index 0, an east exit always goes in index 1, etc. If so, then the size of this array depends on how many directions you want to support. The Room class should also have a constructor that accepts a name and description. Here is an example of how you can write the constructor: public Room (String name, String description) { super(name, description); this.exits = new Room[?]; // size is your choice } } You might also find it convenient to create a getter not just for all the exits, but for a particular exit given a direction. 3. The game package contains the Player class. This class represents the player moving through these rooms. The Player class has the following property: Room currentRoom : the room the player is currently in. Create your getters and setters. 4. The game packag also contains the RoomManager class. This class will be responsible for "loading" our rooms into memory. When the main() method is executed, it should invoke the init() method in this class that will instantiate all our Room objects, link them together as exits, and designate a startingRoom. This class should define (at least) the following properties: Room startingRoom : the room a player should start in. Room[] rooms : all the rooms in the house. Here is an example of a partially implemented init() method: public void init() { // create a room Room foyer = new Room "The Foyer", "The small entryway of a neo-colonial house. A dining room is open to the south, where a large table can be seen." " " + "The hardwood floor leads west into doorway, next to a staircase that leads up to a second floor." + " " + "To the north is a small room, where you can see a piano."); + // add room to array of rooms this.rooms [0] = foyer; // set the house's starting room this.startingRoom = foyer; = // create other rooms and add them to room array // set the exits of each room using their exits' property Lp } 5. The Main class will store the main() method for our game (and of course, it will be the only class that has a main() method). This is where the game- loop will go, where we'll display information to the user, collect input from the user, and parse that input. Add the following code inside of the Main class and note the comments: public static void main(String[] args) { // create objects needed, like a Player object and RoomManager object // loop until user quits // invoke printRoom // invoke collectInput() // invoke parse() } private static void printRoom(Player player) { // display information about the current room and/or other helpful information } private static String[] collectInput() { // use Scanner object to collect console input from the user // divide the input into multiple parts/words // return array of divided input to be parsed } private static void parse(String[] command, Player player) { // parses the user input and makes decision based on input } 6. Fill in the classes and methods. Make sure to import classes from other packages that you'll need! Your home should have at least 3 rooms to navigate through and navigating between them should make sense. For example, if I were to exit the living room and go north to the kitchen, I should be able to get back to the living room by going south. Troubleshoot the program so that it doesn't crash if the user types in input the program doesn't anticipate. 7. Optional step: If you are done with Home Tour and want to add additional features, you can create other Fixture subclasses for the user to interact with, such as doors or items. You can also refactor some arrays to be Maps or other data structures instead, or you can add more than three rooms to create a larger house. Requirements Once you are done with your project, check it against the requirements below to make sure you have included everything: has correct files and packages (the six classes mentioned in the instructions and the two packages) uses the methods uses OOP, such as getters and setters doesn't crash when user enters incorrect input has at least three rooms exits make sense

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

Step: 3

blur-text-image

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

Practical Oracle8I Building Efficient Databases

Authors: Jonathan Lewis

1st Edition

0201715848, 978-0201715842

More Books

Students also viewed these Databases questions

Question

3. How has Starbucks changed since its early days?

Answered: 1 week ago