Question: Please help me write this program. Directions Write a program that allows a user to enter contact information into a phone list. The contact information

Please help me write this program.

Directions

Write a program that allows a user to enter contact information into a phone list. The contact information includes a person's name and phone number.

Class Decomposition

The problem has been decomposed into the following two classes: Contact and PhoneList. The Contact class stores information about each contact.

The Contact class has been provided for you. Copy the following code into a file named

Contact.java

public class Contact

{

private String name;

private String phone;

public Contact(String n, String p)

{

name = n;

phone = p;

}

public String getName()

{

return name;

}

public String getPhone()

{

return phone;

}

}

The PhoneList class is a client of the Contact class. It uses aggregation or a "has a" relationship. The PhoneList manages the program by allowing a user to enter contact information into the program. Once data entry is complete the class displays the contact information entered.

Method Decomposition

Using method decomposition the class can be subdivided into two methods: getContactInfo and printContactInfo. The method getContactInfo is responsible for allowing a user to enter contact information. The method printContactInfo is responsible for displaying the contact information stored in the ArrayList.

Copy the following code into a source file named PhoneList.java.

import java.util.*;

public class PhoneList

{

private ArrayList phoneList = new ArrayList();

public void getContactInfo()

{

}

public void printContactInfo()

{

}

public static void main(String[] args)

{

PhoneList app = new PhoneList();

app.getContactInfo();

app.printContactInfo();

}

}

Sample Run

Enter name -->John Wayne

Enter phone number -->382-4328

Continue [Y or N]? y

Enter name -->Jimmy Stewart

Enter phone number -->565-1122

Continue [Y or N]? y

Enter name -->Marilyn Monroe

Enter phone number -->387-9999

Continue [Y or N]? y

Enter name -->Henry Fonda

Enter phone number -->394-5434

Continue [Y or N]? n

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!