Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create UML 1. Design a Contact class as follows a. Four private instance variables i. name, a string. ii. address, a string. iii. phone, a

Create UML 1. Design a Contact class as follows

a. Four private instance variables i. name, a string. ii. address, a string. iii. phone, a string. iv. email, a string. b. Public getters and setters for each instance variable. c. A public method named toString which returns a single String containing all of the instance variable values separated by tab characters (\t). 2. Design a ContactBook class as follows a. One private instance variable named entries which holds an array of Contact objects. b. Three public void methods... i. add, which takes a Contact object as a parameter and adds it to the entries array. ii. update, which takes an int and a Contact object as parameters and replaces the Contact in entries at that ints position with the parameter Contact. iii. remove, which takes an int as a parameter and removes the Contact in entries at that position, moving the remaining Contacts up in the array to replace it. c. A public method named toString which returns a single String containing the following data for each Contact object in the array: i. The Contacts index number in the array. ii. The result of the Contacts toString() method. iii. A new line character ( ). 3. Draw any appropriate relationship lines (aggregation/composition) between these two classes.

Design the App 1. Create a Java project with a main class called ContactApp inside of a package .

2. Create the Contact class using your UML class diagram and the design requirements as a guide.

3. Create the ContactBook class using your UML class diagram and the design requirements as a guide. a. For the add method, remember that arrays cannot be resized! You must copy your existing array in to a new array that is one element larger. b. Similarly for the remove method, you must copy your existing array in to a smaller array. However, doing this using Arrays.copyOf will remove whatever is in the last position of your array, so plan carefully! (Continued on next page) (Continued from Implementing Project 5)

4. Inside of the main method for ContactApp use your classes and objects as implemented to perform the following steps: a. Create a ContactBook object. b. Repeat the following steps in a loop until the user chooses 5. i. Using the above Sample Results as a guide, print a menu with the five choices shown. ii. Ask the user to choose a menu item. iii. Ask for the appropriate inputs (see Sample Output) based on the users menu choice and use the ContactBook object to make the appropriate changes. 1. Note that to List All Contacts you should be able to simply print the results of your ContactBooks toString method.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional IPhone And IPad Database Application Programming

Authors: Patrick Alessi

1st Edition

0470636173, 978-0470636176

More Books

Students also viewed these Databases questions