CASE STUDY^567
importjava.io.;
importaddressBook.;
importlist.*;
public classMergeBooks
{
public static voidmain(String[] args) throwsIOException
{
// Declare files and lists
ObjectInputStream firstFile;
ObjectInputStream secondFile;
ObjectOutputStream outFile;
PrintWriter labelFile;
SortedList firstList; // First list of entries
SortedList secondList; // Second list of entries
SortedList resultList; // Combined list of entries
// Declare an entry for each list
EntryPlus firstEntry;
EntryPlus secondEntry;
EntryPlus resultEntry;
// Declare a counter for each list
intfirstCount;
intsecondCount;
booleanmoreData1; // More data in firstList
booleanmoreData2; // More data in secondList
// Declare variables for the number of entries in each list
intfirstLimit;
intsecondLimit;
intresultLimit;
intcompareResult; // Result from a comparison
// Prepare files
firstFile = newObjectInputStream(newFileInputStream("adBook1.dat"));
secondFile = newObjectInputStream(newFileInputStream("adBook2.dat"));
outFile = newObjectOutputStream(newFileOutputStream("adBook3.dat"));
labelFile = newPrintWriter(newFileWriter("labels.out"));
// Create the two lists of entries
firstList = newSortedList();
secondList = newSortedList();