Programming and Problem Solving with Java

(やまだぃちぅ) #1

CASE STUDY^363


//**

// This class is a driver that creates entries made up of a
// name, an address, a phone number, and a date. The name, address,
// and phone number are read from a file. The birthday is read
// from the screen. Each entry is written to a file of EntryPlus
// objects.
//**


importjava.io.;
importjava.util.
;
importaddressBook.*;
public classPlusDriver
{
public static voidmain(String[] args) throwsIOException
{
// Declare instance variables
Name name;
Address address;
Phone phone;
EntryPlus entry;
GregorianCalendar birthday;
// String and integer variables used for input
String first, last, middle, street, city, state, zip;
intareaCode, number, month, day, year;


// Set up input files including screen
BufferedReader inFile;
inFile = newBufferedReader(newFileReader("Entries"));

BufferedReader in; // To input birthday
// Instantiate in using System.in
in = newBufferedReader(newInputStreamReader(System.in));

// Set up output file of objects
ObjectOutputStream outObject;
outObject =
newObjectOutputStream(newFileOutputStream("EntryObjects"));

first = inFile.readLine(); // Read in first name
while(first != null)
{
Free download pdf