Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Imagine we were creating a Textbased Adventure program and our Rooms in the assignment above could hold Items. We are not writing the complete game,

Imagine we were creating a Textbased Adventure program and our Rooms in the assignment above could hold Items. We are not writing the complete game, but lets write a program that will build the Item.txt file. Create a new project. Add a class called Item that stores information about an item that can be placed in a room. An item has a name, a description and the room number in which the item is initially is stored. LAMP, a brightly shining lamp, 3 is an example of data that an Item might contain. Using the UML model below, create the private data members and methods for constructing an item. Create an ItemFileWriter class with a static method to write the items from the given ArrayList to a text file.. The items text file will hold the item name, item description and the initial room that the item is to be loaded into, on seperate lines followed by a blank line. An example of the file that is to be constructed is attached. Construct a class with main() in it. Create an ArrayList of Items and get the item data from the user for as many items as the user wants to type in. After the user finishes inputting the items, write them to the Items text file using your ItemFileWriter. Next, have main() display how many items were written to the file. Be sure to fully document all classes. Item -itemName: String the name of the item -itemDescription: String the description of the item -initialRoom: int initial room the item will be put in +Item(name:String,descr:String,room:int) Constructor. This just sets the instance variables to the values of the parameters +getItemName(): String returns the name +getInitialRoom(): int returns initial room number +toString():String returns a string with the name and description

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

1. How will you, as city manager, handle these requests?

Answered: 1 week ago

Question

1. Identify the sources for this conflict.

Answered: 1 week ago