CS401 | sw engineering
  • outline
  • projects
  • syllabus
  • links

Sample Session -user choosing Menu Items in no particular order.


NOTE: user input below shown in red

NOTE: the starting state had 2 entries in the AddressBook ---only to make it easier for me to have something in book --not part of design.

NOTE : (see below)as I did not stipulate what would happen when you try to add 2 of the same entires I will allow you to decide what to do ---is this a design flaw or something you need to decide as a programmer? You can allow duplicates or not --but, see discussion at the bottom of this base of a use of a datastructure for AddressBook.addressEntryList that does not allow duplicates.

 


*************************
Please enter your menu selection
a) Loading From File
b) Addition
c) Removal
d) Find
e) Listing
f) Quit
*************************

e 

 


1: Sterling Jeppson
2759 Vine Dr.
Livermore, CA 94550
sterlingijeppson@gmail.com
925-289-6963

 

2: D.S Malik
2759 Vine Dr.
Livermore, CA 94550
sterlingijeppson@gmail.com
925-289-6963

 

 

*************************
Please enter 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:
99999
Email:
l@gmail.com
Telephone:
222233233

 


*************************
Please enter your menu selection
a) Loading From File
b) Addition
c) Removal
d) Find
e) Listing
f) Quit
*************************

e


1: Lynne Grewe
123 3rd avenue
hayward, ca 99999
l@gmail.com
222233233

 

2: Sterling Jeppson
2759 Vine Dr.
Livermore, CA 94550
sterlingijeppson@gmail.com
925-289-6963

 

3: D.S Malik
2759 Vine Dr.
Livermore, CA 94550
sterlingijeppson@gmail.com
925-289-6963

 

 

*************************
Please enter your menu selection
a) Loading From File
b) Addition
c) Removal
d) Find
e) Listing
f) Quit
*************************

b


First Name:
Jane
Last Name:
Ostrich
Street:
3423 Apple Street
City:
San Francisco
State:
CA
Zip:
93939
Email:
apple@gmail.com
Telephone:
388393939

 


*************************
Please enter your menu selection
a) Loading From File
b) Addition
c) Removal
d) Find
e) Listing
f) Quit
*************************

e


1: Lynne Grewe
123 3rd avenue
hayward, ca 99999
l@gmail.com
222233233

 

2: Sterling Jeppson
2759 Vine Dr.
Livermore, CA 94550
sterlingijeppson@gmail.com
925-289-6963

 

3: D.S Malik
2759 Vine Dr.
Livermore, CA 94550
sterlingijeppson@gmail.com
925-289-6963

 

4: Jane Ostrich
3423 Apple Street
San Francisco, CA 93939
apple@gmail.com
388393939

 

 

*************************
Please enter your menu selection
a) Loading From File
b) Addition
c) Removal
d) Find
e) Listing
f) Quit
*************************

a


Enter in FileName:
entries.txt


*************************
Please enter your menu selection
a) Loading From File
b) Addition
c) Removal
d) Find
e) Listing
f) Quit
*************************

e


1: Jane Beppson
1231 Fun St.
Oakland, CA 12345
fun@gmail.com
323-234-5623

2: Maddie Felix
2 Fifth Street
Hayward, CA 95010
felix@yahoo.com
510-234-5678

 

3: Lynne Grewe
123 3rd avenue
hayward, ca 99999
l@gmail.com
222233233

 

4: Sterling Jeppson
2759 Vine Dr.
Livermore, CA 94550
sterlingijeppson@gmail.com
925-289-6963

 

5: D.S Malik
2759 Vine Dr.
Livermore, CA 94550
sterlingijeppson@gmail.com
925-289-6963

 

6: Sterling Nelson
1111 Address St.
Oakland, CA 12345
sij@gmail.com
111-234-5678

 

7: Jane Ostrich
3423 Apple Street
San Francisco, CA 93939
apple@gmail.com
388393939

 

*************************
Please enter 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:
Felix


The following entry was found in the address book.
Maddie Felix
2 Fifth Street
Hayward, CA 95010
felix@yahoo.com
510-234-5678


Hit 'y' to remove the entry or 'n' to return to main menu
y


*************************
Please enter your menu selection
a) Loading From File
b) Addition
c) Removal
d) Find
e) Listing
f) Quit
*************************

e


1: Jane Beppson
1231 Fun St.
Oakland, CA 12345
fun@gmail.com
323-234-5623

 

2: Lynne Grewe
123 3rd avenue
hayward, ca 99999
l@gmail.com
222233233

 

3: Sterling Jeppson
2759 Vine Dr.
Livermore, CA 94550
sterlingijeppson@gmail.com
925-289-6963

 

4: D.S Malik
2759 Vine Dr.
Livermore, CA 94550
sterlingijeppson@gmail.com
925-289-6963

 

5: Sterling Nelson
1111 Address St.
Oakland, CA 12345
sij@gmail.com
111-234-5678

 

6: Jane Ostrich
3423 Apple Street
San Francisco, CA 93939
apple@gmail.com
388393939

 

 

*************************
Please enter your menu selection
a) Loading From File
b) Addition
c) Removal
d) Find
e) Listing
f) Quit
*************************

a
Enter in FileName:
entries.txt           NOTE THIS IS THE SECOND TIME READING SAME FILE


*************************
Please enter your menu selection
a) Loading From File
b) Addition
c) Removal
d) Find
e) Listing
f) Quit
*************************

e


1: Jane Beppson
1231 Fun St.
Oakland, CA 12345
fun@gmail.com
323-234-5623

 

2: Maddie Felix         WHY DID IT ONLY add this ONE entry & not duplicates? HINT: datastructure class used for AddressBook.addressEntrryList does not accept duplicates. What will you decide to do? SEE below for optional discussion of what solution created this no-duplicates allowed code.
2 Fifth Street
Hayward, CA 95010
felix@yahoo.com
510-234-5678

 

3: Lynne Grewe
123 3rd avenue
hayward, ca 99999
l@gmail.com
222233233

 

4: Sterling Jeppson
2759 Vine Dr.
Livermore, CA 94550
sterlingijeppson@gmail.com
925-289-6963

 

5: D.S Malik
2759 Vine Dr.
Livermore, CA 94550
sterlingijeppson@gmail.com
925-289-6963

 

6: Sterling Nelson
1111 Address St.
Oakland, CA 12345
sij@gmail.com
111-234-5678

 

7: Jepsom Nelson
1111 Address St.
Oakland, CA 12345
sij@gmail.com
111-234-5678

 

8: Jane Ostrich
3423 Apple Street
San Francisco, CA 93939
apple@gmail.com
388393939

 

*************************
Please enter your menu selection
a) Loading From File
b) Addition
c) Removal
d) Find
e) Listing
f) Quit
*************************

b


First Name:
Peanut
Last Name:
Grow
Street:
389 market ave
City:
Los Angeles
State:
CA
Zip:
393939
Email:
market@yahoo.com
Telephone:
319-293-3838

 


*************************
Please enter your menu selection
a) Loading From File
b) Addition
c) Removal
d) Find
e) Listing
f) Quit
*************************

e


1: Jane Beppson
1231 Fun St.
Oakland, CA 12345
fun@gmail.com
323-234-5623

 

2: Maddie Felix
2 Fifth Street
Hayward, CA 95010
felix@yahoo.com
510-234-5678

 

3: Lynne Grewe
123 3rd avenue
hayward, ca 99999
l@gmail.com
222233233

 

4: Peanut Grow
389 market ave
Los Angeles, CA 393939
market@yahoo.com
319-293-3838

 

5: Sterling Jeppson
2759 Vine Dr.
Livermore, CA 94550
sterlingijeppson@gmail.com
925-289-6963

 

6: D.S Malik
2759 Vine Dr.
Livermore, CA 94550
sterlingijeppson@gmail.com
925-289-6963

 

7: Sterling Nelson
1111 Address St.
Oakland, CA 12345
sij@gmail.com
111-234-5678

 

8: Jepsom Nelson
1111 Address St.
Oakland, CA 12345
sij@gmail.com
111-234-5678

 

9: Jane Ostrich
3423 Apple Street
San Francisco, CA 93939
apple@gmail.com
388393939

 

 

*************************
Please enter your menu selection
a) Loading From File
b) Addition
c) Removal
d) Find
e) Listing
f) Quit
*************************

d
Enter in all or beginning of last name you wish to find:
Gr


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


1: Lynne Grewe
123 3rd avenue
hayward, ca 99999
l@gmail.com
222233233

 

2: Peanut Grow
389 market ave
Los Angeles, CA 393939
market@yahoo.com
319-293-3838

 

 

*************************
Please enter 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:
Gr


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

 

1: Lynne Grewe
123 3rd avenue
hayward, ca 99999
l@gmail.com
222233233

 

2: Peanut Grow
389 market ave
Los Angeles, CA 393939
market@yahoo.com
319-293-3838

 

2

 


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

   Peanut Grow
389 market ave
Los Angeles, CA 393939
market@yahoo.com
319-293-3838

 

y

 


*************************
Please enter your menu selection
a) Loading From File
b) Addition
c) Removal
d) Find
e) Listing
f) Quit
*************************

f


Quitting.

Process finished with exit code 0

 

 

Discussion of No Duplicate option see above

IMPORTANT: as I did not stipulate what would happen when you try to add 2 of the same entires I will allow you to decide what to do . You can have duplicates or not --you decide.

 

ONE WAY TO ACHIEVE NO DPULICATES: HERE is a well thought out datastructure that allows for multiple AddressEntries with the same last name but, NOT everything in the AddressEntry can be the same, meaning no duplicates. AND it maintains the order! Yes this is a bit more complicated than a simpler datastructure that may allow duplicates.

for example: consider the use of TreeMap where the key=lastName can map to multiple entries in the TreeSet
          private final TreeMap<String, TreeSet<AddressEntry>> addressEntryList = new TreeMap<>();


* Will use TreeMap where the key is a String(the last name of the AddressEntry and the value is the a TreeSet
* AddressEntry. This is because java does not contain a multiset in standard libraries.
* Tree is used instead of hash because tree preserves the natural ordering of key which makes printing in
* sorted order by last name(key) easy.

NOTE: TreeSet implements the SortedSet interface. So, duplicate values are not allowed 

 

cs401:sw engieering

  • home
  • outline
  • projects
  • syllabus
  • links