Program Functionality(Total 80 Points) Part I (10 pts) Write an AddressBook clas
ID: 3648667 • Letter: P
Question
Program Functionality(Total 80 Points)Part I (10 pts) Write an AddressBook class to search the address or the phone of your present friends and to also add new friends to your address book. Use a GUI similar to the images below to manipulate the address book:
Part II (15 pts) Then write a Friend class. To do this, you can extend a Person class, which contains only the names of a person. Then you can extend the Person class to a Friend class to hold the additional data fields for the address and phone numbers. It would be also be best to create an Address class and then add an Address object data field to the Friend class.
The application should start by reading an input file ( 4 or 5 lines of data regarding friends is enough). Each line in the input file should have data about the full name of a friend, his/her full address and his/her phone numbers.
Once you read a complete record/line from an input file, create a Friend object for that record. Then choose and use one of the Java Collection classes discussed in Chapter 22 ( e.g. LinkedList, ArrayList) to create a list of Friend objects ( do not use an array for the list
Explanation / Answer
import java.io.*; import java.util.*; public class Address{ //Declare variables String first; String last; String homeadd; String homeph; String cellnum; Scanner sc = new Scanner(System.in); public Address(String firstName, String lastName, String homeAddress, String homePhone, String cellNumber){ first=firstName; last=lastName; homeadd=homeAddress; homeph=homePhone; cellnum=cellNumber; } public void printMenu(){ System.out.println("1. Add a person to the address book."); System.out.println("2. See if a person is in the address book."); System.out.println("3. Print the address book."); System.out.println("4. Save the address book to disk."); System.out.println("5. Load the address book from disk."); System.out.println("6. Terminate the program."); int answer = sc.nextInt(); //Switch to navigate menu switch (answer){ case 1: getaddress(); printMenu(); break; case 2: //make method to search then print yes/no break; case 3: print(); //make a method to print printMenu(); break; case 4: getaddress(); //getaddress is unfinished break; case 5: getbook(); break; case 6: System.exit(0); break; default: System.out.println("Enter a number between 1 and 6."); printMenu(); } } Address(){ } double contacts[]; //Get address public void getaddress(){ System.out.println("How many contacts do you want to add?"); int number= sc.nextInt(); contacts = new double [number]; for( int i = 1; iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.