Question: Please fix the following two files from the same question. Please only change the FIXME portions. Thanks! HERE ARE INSTRUCTIONS You will be building an
Please fix the following two files from the same question. Please only change the FIXME portions. Thanks!
HERE ARE INSTRUCTIONS
You will be building an ArrayList to represent a phone book.
(1) Complete the following two files
PhoneBookEntry.java - Class definition
PhoneBook.java - Contains main() method
(2) Complete the PhoneBookEntry class per the following specifications:
Private fields
String name
String phoneNumber
Constructor with name and phoneNumber as parameters (in that order)
Public member methods
getName() - Accessor
getPhoneNumber() - Accessor
setPhoneNumber(String number) - Mutator
printPhoneBookEntry()
(3) Complete the PhoneBook class per the following specifications:
Private field
ArrayList
Default constructor.
Public member methods
getEntry(String name)
addEntry(String name, String number)
removeEntry(String name)
editEntry(String name, String number)
lookUpPhoneNumber(String name)
printBook()
(4) In main() method
prompt the user for three phone book entries and add them to the list.
Call the proper method to look up the phone number for Roxanne Hughes.
Call the proper method to update Roxanne Hughes' phone number.
Call the proper method to remove the entry of Juan Alberto Jr.
Output the list again.
____________________________________________________________________________
public class PhoneBookEntry { /*FIXME(1) Define two fields: name and phoneNumber. Both fields are of String type*/ /*FIXME(2) Define a consructor that takes two argument: name, phoneNumber. Parameters are name followed by phone number. */ /*FIXME(3) Define a getter method for the name field*/ /*FIXME(4) Define a getter method for the phoneNumber field*/ /*FIXME(5) Define a setter method for the phoneNumber field*/ public void printPhoneBookEntry() { System.out.println("Name: " + name); System.out.println("Phone Number: " + phoneNumber); } }
_________________________________________________________________________
import java.util.ArrayList; import java.util.Scanner;
public class PhoneBook { /*FIXME(1) Define one field: list, which is an ArrayList of PhoneBookEntry*/ public PhoneBook() { list = new ArrayList
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
