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. Hint: Think of a way to pause the program after a certain number of lines are displayed.

This project can be written by making modifications to ClassObjectIODemo, Listing 10.9, however the PetRecord class does not have the useful readInput() and toString() methods as Species, so they have been added. Also, note that PetRecord must implement Serializable.


See the code in PetRecord.java and PetFileReadOrWrite.java

Computer Science & Information Technology

You might also like to view...

The ____ statement executes an action in a procedure.

A. Sub B. Option Compare C. DoCmd D. Run

Computer Science & Information Technology

An implementation of the _________ interface configures the database connection and prepares query statements automatically.

a. ResultSet b. RowSet c. Both of the above d. Neither of the above

Computer Science & Information Technology

What type of routing algorithm does RIP employ, and where is RIP used?

What will be an ideal response?

Computer Science & Information Technology

Start a Sender process with a message of your choice first, then two or more receiver processes.

This exercise is based on Example1 presented in this chapter. Compile the Example1*.java programs, then execute them in each of the following sequences, describe and explain the outcome of each:

Computer Science & Information Technology