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
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
Chapter12: Using Controls
Section: Chapter Questions
Problem 12E
Related questions
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, 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
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 3 images
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
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,