Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a class called Gadget that implements the interface Serializable with the following instance data and methods: Instance data: String name: name of a gadget

Create a class called Gadget that implements the interface Serializable with the following instance data and methods: Instance data: String name: name of a gadget double price: price of a gadget Methods: Constructor Getter/setter methods for all instance data toString method: prints information of the instance data b) A text file named textInput.txt is given, which has the following format (comma-separated value): (name of gadget), (price of gadget) (i.e., Oculus Rift, 529.00) c) This file can be downloaded from the Moodle. The file has only four lines. d) Your Java program (which is different from the Gadget class) should read each line of the file using BufferedReader, create a Gadget object with the given information, put it in an array (the array size is 6). e) Serialize the Gadget objects and write them to a file called objectOutput.dat. f) Create two more Gadget objects in your program, which you would like to receive as Christmas gifts. g) Serialize those two Gadget objects and write them to the same file objectOutput.dat. Make sure that your program appends the objects in the file, not overwrite the existing objects. h) Read the objects from the file objectOutput.dat, deserialize them, and put them into another array which is different from the previous array. i) Print the information of each Gadget object in the following format: The price of (name of gadget) is $(price of gadget). (i.e., The price of Oculus Rift is $529.00.) (All in Java coding).

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

Students also viewed these Databases questions