CS3340:  Intro OOP and Design

Project 1

Due October 25 midight

Address Book Console Application

 

Points 200


GOAL and Outcomes:

This project will serve you in developing your OOP skills through developing an Address Book Console Application that requires assembling a solution out of modular classes, giving each class a good API for its client(s) and testing. This requires:

  • you to do "Divide and Conquer" a strength of OOP design that lets you use modularity and encapsulation to divide a problem into more than one smaller problem.
  • you to develop Unit Testing Code - taking in part advantage of some Test Driven (maybe we should call it Test Assisted) Design/Implementation.
  • use of Collections in Java to implement Data Structures need.
  • you to efficiently solve some of the problem using algorithms you learned about in Data Structures and Algorithms class. You want to write classes (methods) that run quickly.
  • you to create a single, static AddressBook instance that all other classes and the client code will access. In OOP, this is sometimes called a "singleton" pattern, since there is only one instance of the object and the other classes are always given a point to that one instance.
  • learn how to use Git, eGit with Eclipse and Bitbucket

 

Classes

I am going to help you out by paritally specifying some of the OOP design you MUST adhere to. Here is a list of classes that you must implement and their meanings:

  • AddressBook - this class represents and contains a possibly every growing and/or shrinking "list" of AddressEntries. It allows for various operations such as search/find, addition and removal of AddressEntries.
    • you need to think about the efficiency of operations needed --see below example session --list alphabetic order (sorted), add, remove, find (search), read in from file

  • AddressEntry - this class represents a single Address/Contact information entry in the AddressBook
    • It should contain contructors, at least one constructor…one that accepts a first, last name, street, city, state, zip, email, phone.
    • contain separate class varaibles representing all the information in an AddressEntry contact.
    • It should cotain a toString() method that returns a nicely formats a string containing all contact information for printing to console
    • It should contain setX() and getX() methods where X are the class variables. (for example, setName(***) and getName() where *** are appropriate parameter(s) )

  • AddressBookApplication - this contains the main application class.
    • Uses Menu classes and AddressBook as described in this document.

  • Menu- this class is used to display menu options to the user. This includes
    • a) Loading of entries from a file.
    • b) Addition - prompting user for information to be used to create a new AddressEntry
    • c) Removal - removing of an AddressEntry from the AddressBook. First a find is done (see below example session) and then the user selects from the find results what entry to remove.
    • d) Find - prompts users for the begining of the users last name (they can enter a complete last name or just the start....all entries with that as the first part of their last name will be displayed). Note in the case when more then one entry is found a set will be returned.
    • e) Listing - listing (a "dump") of the addresses in alphabetic order by the person's last name.
    • f) Quit -note we are NOT saving any newly created AddressEntry objects (or removing objects either are not updated to the file) to the file, this data is lost, we will handle this issue in Project 2 when we store data more apporpriately in a database.

    Start of a UML Class Diagram showing the Classes you will create and SOME of the methods you will need

Unit Testing

Work on your unit-tests before getting in too deep writing your Address Book Application code. You must create a test class for every class you create. For example, for the AddressBook class create a JUnit unti testing class called AddressBookTest. Writing the tests at the start (or almost) helps you get started thinking about methods and and use cases are before you write the code. Then, having the tests in place makes it easy to see if your code is working as you build out the code for the various cases.

I will look at the unit testing code as follows:

  • A baseline of having a decent looking unit-test: For a particular test class you should test its corresponding class's methods at least 2 times for each method (this is a minimum). For example, the AddressBookTest unit test should look at 2 or more different istantiations of an AddressBook using its constructor, it should call and check the output of each of its methods --addAddress,getAddress, equals, find, lessThan, greaterThan at least 2 times for each method. Note in this case the AddressBookTest will have methods of testAddressBook, testAddAddress, testGetAddress, testEquals, testFind, testLessThank, testgreaterThan, etc.
  • When run against a correct class, each unit test class's methods should not report any problems.
  • If someone (meaning me or you) were to intruduce some error in a class then the corresponding testing Class should show the failure. Your unit test must show that there is a problem but, does not need to tell exactly what the problem is....that is what you do with debugging using the unit testing failure information/indication.
  • SPECIAL NOTE: I always get at least one question and welcome all questions from a student(s) saying they don't feel comfortable or understand how to write testing code. You have to start somewhere and frankly there is OFTEN not ONE set of lines that make up the best testing code. But, I am looking for something decent not perfect. Comein and see me about this during office hours if you want help.

 

Example Session

format of this session is up to you....the content is what is important

NOTE: white shows the text output by the program, purple shows the input typed in by the user

*****************************
Please enter in your menu selection
a) Loading From File

b) Addition

c) Removal

d) Find

e) Listing

f) Quit
*****************************

 

> a

Enter in FileName:
> AddressInputDataFile.txt

Read in 21 new Addresses, successfully loaded, currently 21 Addresses

 

*****************************
Please enter in your menu selection
a) Loading From File

b) Addition

c) Removal

d) Find

e) Listing

f) Quit
*****************************

>b

First Name:
> Lynne

Last Name:
> Grewe

Street:
> 123 3rd Avenue

City:
> Hayward

State:
> CA

Zip:
> 93922

Phone: xxx-aaa-bbbb
> 510-486-1234

Email:
> lynne.grewe@csueastbay.edu

Thank you the following contact has been added to your address book:
Lynne Grewe
123 3rd Avenue
Hayward, CA 93922
lynne. grewe@csueastbay.edu
510-486-1234

 

*****************************
Please enter in your menu selection
a) Loading From File

b) Addition

c) Removal

d) Find

e) Listing

f) Quit
*****************************

>c

Enter in Last Name of contact to remove:

>Grewe

The following 2 entries were found in the address book, select number
of entry you wish to remove:

1: Lynne Grewe
   123 3rd Avenue
   Hayward, CA 93922
   lynne. grewe@csueastbay.edu
   510-486-1234

2: Jack Grewe
   2922 Orchard Streeet
   Boston, MA 32992
   
   413-571-1234

> 2

Hit y to remove the following entry or n to return to main menu:

   Jack Grewe
   2922 Orchard Streeet
   Boston, MA 32992
   
   413-571-1234

>y

You have successfully removed the Jack Grewe contact

 

*****************************
Please enter in your menu selection
a) Loading From File

b) Addition

c) Removal

d) Find

e) Listing

f) Quit
*****************************

>d

Enter in all or the begining of the Last Name of the contact you wish to find:

>Grew

The following 2 entries were found in the address book for a last name starting with "Grew":

1: Jane Grewan
   56th street
   SF, CA 95233
   grewan@yahoo.com
   415-432-1234

2: Jack Grewe
   2922 Orchard Streeet
   Boston, MA 32992
   
   413-571-1234

 

*****************************
Please enter in your menu selection
a) Loading From File

b) Addition

c) Removal

d) Find

e) Listing

f) Quit
*****************************

>e

1: Bee Apple
   284 Woodside Avenue
   Woodside, IN 23902
   bee.apple@yahoo.com
   317-923-4832

2: Jane Grewan
   56th street
   SF, CA 95233
   grewan@yahoo.com
   415-432-1234

3: Jack Grewe
   2922 Orchard Streeet
   Boston, MA 32992
   
   413-571-1234

not going to list all but, your program would. It should be listed in alphabetic order by last name

*****************************
Please enter in your menu selection
a) Loading From File

b) Addition

c) Removal

d) Find

e) Listing

f) Quit
*****************************

Goodbye!

 

Specifications and Code

  • Before coding, create UML document (see item #5 below) showing your design.
  • DOCUMENT YOUR CODE!!!
  • Think about efficiency in choosing your data structures and algorithms. You can assume that users will equally want to search (find), store to file, read from file, list alphabetically all entries. You must discuss in your code description (see CodeWorks.doc below) why you choose the data structures you did and what is the efficiency for sorting (as you did it), search/find, listing alphabetically
  • You MUST develop Unit Test cases for all of your Classes and their important methods. This is part of the deliverables.
  • See above for information on required Classes.
  • You are encouraged to use Java Collections as appropriate to facilitate data structures you wish to use.
  • User Input Correctness.
    • When user is entering in an AddressEntry you should NOT assume correct data is entered by the user, test to make sure a number is a number, etc. If not, you should PRINT out a message telling the user it is INVALID input and ask again for the input in question. You only have to check for type --- you don't need to see for example if the phone number has a valid area code or if the email address is valid.
  • Create a class named Address that contains String instance variables for street, city, state, and zip code.
    • This class should contain a constructor that accepts values to initialize these variables and methods that return each one
    • toString() method that returns a string for the Address object.
    • setX and getX methods to set/get class variables. (i.e. setStreet, setCity, etc.)
  • As you code, create comments and produce JavaDocs that fully document ALL your classes and upload your JavaDoc files to your account so they are accesible via the web. (see item #2 below)
  • Test your code and store results in file Working.doc (see #1 below).

Git

You are required to create a Git repository locally and on BitBucket called YourLastName_AddressBook hence for me it would be called Grewe_AddressBook. You are to use the repository in developing your code. YOU MUST comment well any commits you make --I will be looking at these.

 



Evaluation Guidelines



Deliverables -MUST KEEP THESE FILENAMES SPECIFIED BELOW.

  1. CodeWorks.doc: contains the following components:
    • A: Description- give a detailed description of how your system works including:
      • A.1) List of Classes: with brief desciption of purpose, discuss any data structures/algorithms used their efficiency in relation to the main operations of our menu - loading, addition, removal, find, listing, saving. Use O(n) terminonlogy where n is the number of entries.
      • A.2) State of System: a description of what parts are or are not working ---give details. If your system is NOT working and you do not show screenshots of how it is failing and show you have through screen shots tried to insert breakpoints and done debugging you will have points taken off.
    • B: Creation of JavaDoc code. You will be turning in a separated folder ziped of all JavaDoc. Every class, its variables and methods MUST be documented/described --not just listed.
    • C: UML/Design: contains the following
      • C.1) UML Class Hierarchy Diagram: showing Hierarchy and Cardinality and Object Associations for this project.
    • D: Working Screenshots: Screen shots showing your Java Application working (capture screen dumps into a word document) for the following cases:
      • D.1) Work Instance 1: Read in entries from a file (menu option a) followed by listing (menu option e). The File must contain a minimum of 5 addresses. Provide contents of file here and label it as input file contents.
      • D.2) Work Instance 2: immediately following D.1 do an addition of new entry (menu option b) followed by a listing (menu option e)
      • D.3) Work Intsance 3: immediately folllowing D.2 do a removal of a entry (menu option c) followed by a listing (menu option e)
      • D.4) Work Instance 4: immediately followin D.3 do a find (menu option d) using input that should retrieve at least one entry. Now do a find using input that should retrieve no entries.
      • D.5) Work Instance 5: performs a quit (menu option e)
    • E: Unit Testing Screenshots: Show screen shots of running JUnit Testing on this code.
    • F: Screen shots showing the BitBucket account and your repository --show Commits, Show Code tree


  2. Code.zip zip file containing Project folder of Code (NOT JUST the java files), so it can be easily incorporated into ECLIPSE IDE. Will assume it is Eclipse IDE UNLESS YOU TELL me in comments of blackboard submission that you used Netbeans instead.
  3. doc.zip zip file containing JavaDocumentation html files generated
  4. Demonstrate Project create a YOUTUBEvideo and turn in URL --must be public (but, can be unlisted). The video should show the application working and discuss ANY problems you have with it.

  5. TURN in all files and Youtube URL for evaluation to blackboard project "Projects->Project 1->Project 1- submit for instructor".

 

© Lynne Grewe