computer science

profilew.2.a
chapter_10_program_the_black_book-1.docx

The Black Book :

Write a program that implements a rudimentary name-finder. It should start out by filling up a name ArrayList with Name objects. Then it should ask the user if he/she wants to find a particular name. Then it should search for the name in the name ArrayList and return the names information if the name is found. Here is a suggested UML class diagram:

Blackbook

-name : ArrayList<Name> = ArrayList<Name>

+filltheblackbook() : void

+getName(first : String) : Name

+main(args : String[]) : void

BlackbookDriver

Name

-first : String

-last : String

-address : String

+Name(first : String, last : String, address : String)

+getName() : String

+toString() : String

Implement Name filltheblackbook method by adding anonymous objects representing these four names:

First Name Last Name Address

Sara Smith 123 N 53rd

Lolita Edwards 672 E 22nd

Kyle Johnson 456 W 29th

Elizabeth Waitsmith 521 S 3rd

Implement Name’s getName method so that if the name is not found, the method returns the string:

"Sorry – that name is not in the black book."

Implement Name’s toString method simply by returning this string value:

First Name + " " + Last Name + " " + Address

Note: Can you write comments in each variables