CASE STUDY^311
// Knowledge responsibilities
publicName knowName()
{
returnname;
}
publicAddress knowAddress()
{
returnaddress;
}
publicPhone knowPhone()
{
returnphone;
}
public voidwriteToFile(PrintWriter outFile)
// State variables are written on file outFile
{
outFile.println(name.knowFirstName());
outFile.println(name.knowLastName());
outFile.println(name.knowMiddleName());
outFile.println(address.knowStreet());
outFile.println(address.knowCity());
outFile.println(address.knowState());
outFile.println(address.knowZip());
outFile.println(phone.knowAreaCode());
outFile.println(phone.knowDigits());
}
}
//**
// This class is a driver that creates entries made up of a
// name, an address, and a phone number. Data are read
// from the screen. Each entry is written to the file Entries.
//**
importjava.io.;
importaddressBook.;
public classAddressDr
{
public static voidmain(String[] args) throwsIOException
{
// Declare local variables
Name name;
Address address;
Phone phone;
Entry entry;
// String and integer variables used for input
String first, last, middle, street, city, state, zip;
intareaCode, number;