Question
Modify the code in Chapter 15s StudentList class in Figure 15.8 so that objects from that class can be written to a fi le. For
Modify the code in Chapter 15s StudentList class in Figure 15.8 so that objects from that class can be written to a fi le. For this exercise, you may simply ignore the dangerous method call in the removeStudent method. Using the WriteObject class in Figure 16.5 as a guide, encode a StudentListFileWriter class that writes three StudentList objects to a fi le called StudentLists , as follows: Construct the fi rst object with the same four names as those used in the StudentListDriver in Figure 15.9, and write it to the fi le. Construct the second object with those same four names plus the additional name Anna, and write it to the fi le. For the third object, use the remove method to remove Izumi from the second object, and write this modifi cation of the second object to the fi le so that it appears as a distinct third object in the fi le. Finally, using the ReadObject class in Figure 16.6 as a guide, encode a StudentListFileReader class that reads and displays all objects in the fi le. Run this StudentListFileReader to confi rm that the fi le holds three objects with different name lists.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started