//created by bond nene** import java.lang.String; import javax.swing.*;//this imports the swing package from the java library import java.io.*; import java.awt.*; import java.awt.event.*; // Test conditions on objects values in a record object: Rooms defined in class at end public class TelephoneDirectorya1a //this declears the main class { public static void sortum(Directory array[], int number, int asize)//this is the sort um function to sort read in values { for (int pass = 0; pass < asize-1; pass++) { for (int counter = 0;counter < asize-1; counter++) { if (array[counter].Number > array[counter + 1].Number) { int temp; temp = array[counter].Number; array[counter].Number = array[counter + 1].Number; array[counter + 1].Number = temp; String temp2; temp2 = array[counter].Surname; array[counter].Surname = array[counter + 1].Surname; array[counter + 1].Surname = temp2; String temp3; temp3 = array[counter].Initial; array[counter].Initial = array[counter + 1].Initial; array[counter].Initial = temp3; } } } } public static void index(int indexarray [], int arraysize)//this is the index array { for (int counter = 0; counter < arraysize; counter++) { indexarray[counter] = counter; } } public static void indexsort(Directory array[], int index[],int arraysize)//this is the index sort function { for (int pass = 0; pass 0) swap(index, counter, counter+1); } } } public static void swap(int a[], int p1, int p2) { int temp = 0; temp = a[p1]; a[p1] = a[p2]; a[p2] = temp; } public static void printindex(Directory arry[], int index[], int arraysize) { for (int counter = 0; counter < arraysize; counter++) { int position = index[counter]; JOptionPane.showMessageDialog(null," sorted surname: " + arry[position].Surname + "\n Initials are: " + arry[position].Initial + "\n telephone number is: " + arry[position].Number); } } public static void main (String[] args) throws IOException//this declears the main arrays and strings { int choice;//this is a decleared integer int ARRAYSIZE = 3;//this is the size of the array Directory[] details = new Directory[ARRAYSIZE];//this declears a new object to be used String[] options = {" RUN PROGRAM","SAVE PROGRAM",">more options<"}; int n = JOptionPane.showOptionDialog(null, "TELEPHONE DIRECTORY PROGRAM" + "\nCLICK ON A VALUE TO USE THE FUNCTION\n" + "\n*************************************************\n** **\n** **\n******|_|THE BLUE ICE DIRECTORY|_|***\n** **\n** **\n***********************************************", "TELEPHONE DIRECTORY ", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[2]); if (n == 0)//if this condition is ture the below code is executed { details[0] = new Directory();//this is an arrray object with values not decleared details[1] = new Directory();//this is an arrray object with values not decleared details[2] = new Directory();//this is an array object with values not decleared choice = Integer.parseInt(JOptionPane.showInputDialog("Input 1 to run the program\n Input 2 to save the file\n input 3 to print the values stored in the file\nInput 4 to search for a value\ninput 5 to sort the values\ninput -1 to quit ")); } if(n == 1)//if this condition is ture the below code is executed { final FileWriter outputfile = new FileWriter ("C:/windows/Desktop/Records.txt"); BufferedWriter outputbuffer = new BufferedWriter(outputfile); PrintWriter printstream = new PrintWriter(outputbuffer); for (int i = 0; i