Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use Linked Lists as a data structure, Required: Contact.java LinkedList.java AddressBook.java AddressBookDemo.java Completion of the addAsSecondNode method in the LinkedList class Any other necessary methods

Use Linked Lists as a data structure,

Required: Contact.java LinkedList.java AddressBook.java AddressBookDemo.java Completion of the addAsSecondNode method in the LinkedList class Any other necessary methods

image text in transcribed

Designa class called AddressBook that utlixes a Linked List to store nodes which are made up of Contacts. Adapt using the provided Node class and adspt & add to the provided Linked List class thst we developed together L Design the Contact class that stores a person's last name, first name, strest name, and phone number private String lastName private String firstName prsate String treetName: pryate String phone //complete the rest of the class by adding appropriate constructors, get, set methods, toString, etc. 2. Re-design the Linkect ist class so that the methods will work with Nodes with Contacts as its data private Node fromt; Boete int count pubic Linkeditix rontnul pubie void addTofroString d nnew Nodeld, fronti pubic int sizell return count eubic boolean sEmptyl return (count publis void clear front- null front .. nu? retum "Empty list eke I return froneate Gets the first Node publik Node RetFrontol return front Scans the list and prints the contents public void enumerateh Node cuer-from publis void print wenindes Node cuer- from while arr -ur.getNexgetNel iflcur getNext brea publik vold printNINodesWith Stringd Node cuer whilk leurr l- nlll Ml METHOD UNFINISHED 3. Re-design the Node class to hold the Contact object as its data. publik class Nodel private String data; prihate Node nest publics Node(String d, Node n dsta ublic String getData0f return data: public Node getNext(l return next public vold setoatalString d data-d: publik void setNexsiNode n next n publics String toStringiK return data 4. Finally, you will create the AddressBook class. It has a LinkedList and methods to edd . contact, display all comacts, search for a specific contact and display it, or search and delete a specific contact Added contacts should be added alphabetically to the LinkedList based on their last names (and then by first name in the case of the same lest names) To addalphabetically look at the sompare To String method which compares Strings lexicographically (returns an int0, cO, orOwhich indicates orderl Displaying al the comacts should beprint formatted to show eults lined up , in columns). Sae the xample Search should let users search orname, address or phone number. Search wifind any contact where any associated instance variable contains the target search string, and prints all matches to the console. For example, elas" is the earchtarget and name is the search category, then any contect where eas is the first name or lest name should be displayed similarly, -5050" ?5 the search target and phone is the search category, a. contacts with 5050 as part of their phone number should be displayed. As well, if the uner searches the Street "Hanslope", it should returm al the address book or e delete method shold search on name, address or phone number (e.g., enters Hanslope to get a lst of all contacts who live on Harslopel. The user wil be presented with a numbered list of contacts (either with all contacts from the address book or from the searchl. Then the user will select the contact from the list to be deleted t to delete from the f Note: you ill need so deal with the situation where a user enbers in a Contact with all the same Information as an eaiting Contact tham all. Make sure you nate in your comments how you are dealing with th Your Addreskcss will look like the UML dingram below AdcressBook: Mnitialaes the Linkedst addContact (Contactad adds the gwan Contact in alphabertical arder removeontact (Contact):vold removes the given Contact t :LinkecLht Wreturra the Linkedlht of Contact search String int: vald enter search word and cabegorv(e-g-1 for rusme, 2 for address,3 for phone Notes yow can add sepporing methods in the dcressBook if needed (make sure you properly comment public static void mainStringtl args) /rest of the code You should write a demo program that implements the AddressBook Your complete program wil have the following A short example of output is below. The demo program should present a menu thet allows the user to add a contact, display allcontacts, search for a specific contact anddisplay it, or search for a specific contact and delete it, and quit. Your output should be nicely formatted. Below is an example screen dialog. Ene i to add contac 210 pay, to seanch, 4 to delete, Stoqu phone umbew 555-1234 Enner i to add contact, 20 spay, Bto seanch, 4 to delete, Stoqt ber phon Emer 1 10 ade contact. 270?pay, 3 to search, 4 10 delete. S to 3 Eer to search nane 2sehaddress3 to search phone ber rown, Adar Ener to ade coetact, 200 dsplay to seanck 4To delete,S to que3 r 2 to search 210 sh adrss3 te seach phone b2 rown, Ada Enei to seach rane. 210 seanch address, 3 to seach phone numbesr, 4 to dsplay all contacts Eer what to seah Rob Entry to deletes Enter 1.00add oeact, 2 todsplay 31e searh 40o delte 5 1e uit: 2 Enter 1 5oadd cantact, 3 to diiplay, 3to search, ta delete, 5tout:s Designa class called AddressBook that utlixes a Linked List to store nodes which are made up of Contacts. Adapt using the provided Node class and adspt & add to the provided Linked List class thst we developed together L Design the Contact class that stores a person's last name, first name, strest name, and phone number private String lastName private String firstName prsate String treetName: pryate String phone //complete the rest of the class by adding appropriate constructors, get, set methods, toString, etc. 2. Re-design the Linkect ist class so that the methods will work with Nodes with Contacts as its data private Node fromt; Boete int count pubic Linkeditix rontnul pubie void addTofroString d nnew Nodeld, fronti pubic int sizell return count eubic boolean sEmptyl return (count publis void clear front- null front .. nu? retum "Empty list eke I return froneate Gets the first Node publik Node RetFrontol return front Scans the list and prints the contents public void enumerateh Node cuer-from publis void print wenindes Node cuer- from while arr -ur.getNexgetNel iflcur getNext brea publik vold printNINodesWith Stringd Node cuer whilk leurr l- nlll Ml METHOD UNFINISHED 3. Re-design the Node class to hold the Contact object as its data. publik class Nodel private String data; prihate Node nest publics Node(String d, Node n dsta ublic String getData0f return data: public Node getNext(l return next public vold setoatalString d data-d: publik void setNexsiNode n next n publics String toStringiK return data 4. Finally, you will create the AddressBook class. It has a LinkedList and methods to edd . contact, display all comacts, search for a specific contact and display it, or search and delete a specific contact Added contacts should be added alphabetically to the LinkedList based on their last names (and then by first name in the case of the same lest names) To addalphabetically look at the sompare To String method which compares Strings lexicographically (returns an int0, cO, orOwhich indicates orderl Displaying al the comacts should beprint formatted to show eults lined up , in columns). Sae the xample Search should let users search orname, address or phone number. Search wifind any contact where any associated instance variable contains the target search string, and prints all matches to the console. For example, elas" is the earchtarget and name is the search category, then any contect where eas is the first name or lest name should be displayed similarly, -5050" ?5 the search target and phone is the search category, a. contacts with 5050 as part of their phone number should be displayed. As well, if the uner searches the Street "Hanslope", it should returm al the address book or e delete method shold search on name, address or phone number (e.g., enters Hanslope to get a lst of all contacts who live on Harslopel. The user wil be presented with a numbered list of contacts (either with all contacts from the address book or from the searchl. Then the user will select the contact from the list to be deleted t to delete from the f Note: you ill need so deal with the situation where a user enbers in a Contact with all the same Information as an eaiting Contact tham all. Make sure you nate in your comments how you are dealing with th Your Addreskcss will look like the UML dingram below AdcressBook: Mnitialaes the Linkedst addContact (Contactad adds the gwan Contact in alphabertical arder removeontact (Contact):vold removes the given Contact t :LinkecLht Wreturra the Linkedlht of Contact search String int: vald enter search word and cabegorv(e-g-1 for rusme, 2 for address,3 for phone Notes yow can add sepporing methods in the dcressBook if needed (make sure you properly comment public static void mainStringtl args) /rest of the code You should write a demo program that implements the AddressBook Your complete program wil have the following A short example of output is below. The demo program should present a menu thet allows the user to add a contact, display allcontacts, search for a specific contact anddisplay it, or search for a specific contact and delete it, and quit. Your output should be nicely formatted. Below is an example screen dialog. Ene i to add contac 210 pay, to seanch, 4 to delete, Stoqu phone umbew 555-1234 Enner i to add contact, 20 spay, Bto seanch, 4 to delete, Stoqt ber phon Emer 1 10 ade contact. 270?pay, 3 to search, 4 10 delete. S to 3 Eer to search nane 2sehaddress3 to search phone ber rown, Adar Ener to ade coetact, 200 dsplay to seanck 4To delete,S to que3 r 2 to search 210 sh adrss3 te seach phone b2 rown, Ada Enei to seach rane. 210 seanch address, 3 to seach phone numbesr, 4 to dsplay all contacts Eer what to seah Rob Entry to deletes Enter 1.00add oeact, 2 todsplay 31e searh 40o delte 5 1e uit: 2 Enter 1 5oadd cantact, 3 to diiplay, 3to search, ta delete, 5tout:s

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

Database Management With Website Development Applications

Authors: Greg Riccardi

1st Edition

0201743876, 978-0201743876

More Books

Students also viewed these Databases questions