Revise the class Pet, as shown in Listing 6.1 of Chapter 6, so that it is serializable.

Question:

Revise the class Pet, as shown in Listing 6.1 of Chapter 6, so that it is serializable. Write a program that allows you to write and read objects of type Pet to a file. The program should ask the user whether to write to a file or read from a file. In either case, the program next asks for the file name. A user who has asked to write to a file can enter as many records as desired. A user who has asked to read from a file is shown all of the records in the file. Be sure that the records do not scroll by so quickly that the user cannot read them. Think of a way to pause the program after a certain number of lines are displayed.


Listing 6.1

/** Class for basic pet data: name, age, and weight. */ public class Pet { private String name; private int age; private double weight; //in pounds //in years public Pet () { Default constructor name =

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Question Posted: