Question: 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, 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 Itemname: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
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
