Question: Part 3 : Create a text file. The text file must have each line in the input file represent one item. The line must include

Part 3:
Create a text file. The text file must have each line in the input file represent one item. The line must include the following values separated by tab: (1) an int to specify whether the line represents an ItemA, ItemB, or Item object of no subtype respectively, (2) string value, (3) integer value, and (4) an Integer value for ItemA or boolean value for ItemB.
For instance, suppose your Item class were Pet, where your parameters were pet name and weight. Your file might have looked like this:
Fido 20
Callie 14
Polly 1
Snoopy 12
Clifford 52
Felix 11
Dumbo 750
The new file would also have an int in the first field indicating the subtype of Pet, and a final field indicating the new instance variable. Lets say the new instance variable for Dog was age, and the new field for Cat was isMale. Then the new input file would look something like this (if the types of Pet were Dog =1, Cat =2, no subtype =3).
1 Fido 208
2 Callie 14 false
3 Polly 1
1 Snoopy 1212
1 Clifford 5280
2 Felix 11 true
3 Dumbo 6000

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!