Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Use Linked Lists as a data structure, NOTE: - THE USE OF Import.java.util.LinkedList; IS PROHIBITED - HOWEVER, BOTH LinkedList class AND Node class ARE PROVIDED
Use Linked Lists as a data structure,
NOTE:
- THE USE OF Import.java.util.LinkedList; IS PROHIBITED
- HOWEVER, BOTH LinkedList class AND Node class ARE PROVIDED BELOW
Required: Contact.java
LinkedList.java
Node.java
AddressBook.java
AddressBookDemo.java
Any other necessary methods
Designaclass called Addresllook that utilires aLinked List to store nodes which are made up of Contacts. Adapt using the provided Node class and adapt & add to the proided Linked List class that we developed topether 1 Design the Contact class that stores a person's last name, first name, street name, and phone number gublic class Contact prvate String astame private String firstName prvate String streetName private String phone; /complete the rest of the class by adding appropriate constructors, get, set methods, toString, etc 2 Re-design the Linkedl ist class so thet the methods will work with Nodes with Contacts as its dsta gublic class LinkedListi g2tx counters 0; erivate Node front, nivate int count sublic Linkeatisto ront- count na new bdeld, front; count+ public ing size( retum count public boolean iE metyl return Icount pubievoidckar front- nuil; ount Frontnul Empty ist eturn front.setotall /Gets the first Node retum front /Scans the ist and prints the contents p-bir void enumerate Node gu- front while lcurr p bir void print venlindes Node -front break Node gu-front while lcurr u cointer at lled 3 Re-design the Node class to hold the Contact object as its data public class Nodel private String data; pvae Node nest, p bic NodelString d, Node n pabic String BedstalN return data gabic Node getNextk return nest pubie void DtaString dI data-d pubic Stringe tostrinel Finally, you will create the Adresslook class It has a Linkedlist and methods to adda contact,display al contacts, search for a specific contact and display it, or search and delete a specific contact Added contacts should be added alphabeticaly to the Linkedl ist based on their last names land then by first name in the caseof the same last names). To add alphabetically lookat the compareTo String method which compares Strings lexicographically (returns an int 0, c, or Owhich ind cates order) Displaying all the contacts should be print formatted to show results lined up eg, in columns). See the eample earch shold let users search on name, address or phone number, Searchwill find any contact where any associated instance variable eontains the target search string, and prints all matches to the console. For example, it elas is the earch target and name is the search category, then any contact where elias is the first name or last name should be displayed. Similarly, i So60 is the search taget and phone the search category, all contacts with S050 as part of their phone number should be displayed. As well, if the user searches the Street Harelope", it should return all the contacts that ive on Harslope Street. t to delete from the rfrom ? earch on name, address or phone number (ef, ereers Hansope to get a list of all contacts ?he live on Hanslope the user will be presented with ? numbered list of contacts feither with-contacts from the address book or from the search). Then the user wil select the contact from the Est to be deleted. Nhe: you ell need to deal with the situation whereuse, erters in. Certaetwth all thesame ilormaton as anexisirE Cornact. could delete hat has dplicate entries you Your AddressBookclass will look ike the UML diagrambelow + 2acotes icontact! : void //addthe giver, Costact is alphabeticalQE ?? removecontact IContact):vold Wremoves the given Contact tLht Linked.ht Nreturra the Linedixt of Contact earch [Strirg, brti : void //erter tearch word .nd tatrgory|?.E-1 for narrw. 2 for .tthen. 3 fy phone) None you canaldsupporting methods is the AddessBook if needed Imake sure you properly conent public statie void mainStringll ansk /rest of the code Youshould write a demo program that implements the AddessBook. Your complete program will have the following A short esample of output is below. The demo program should present a menu that allows the user to add a contact dsplay all contacts, search for a specific contact and display it, or search for a specific contact and delete it, and quit Your output should be nicely formatted. Below is an example screen dalog. nr 1 to seach name. 20oseachaddress 31 searth phon rown, Adar ri bo seach sane 200 seanch address inter what to seanch: Robile to earch phone n Entry to delets: Roble search 4 to dete 3 to qu Designaclass called Addresllook that utilires aLinked List to store nodes which are made up of Contacts. Adapt using the provided Node class and adapt & add to the proided Linked List class that we developed topether 1 Design the Contact class that stores a person's last name, first name, street name, and phone number gublic class Contact prvate String astame private String firstName prvate String streetName private String phone; /complete the rest of the class by adding appropriate constructors, get, set methods, toString, etc 2 Re-design the Linkedl ist class so thet the methods will work with Nodes with Contacts as its dsta gublic class LinkedListi g2tx counters 0; erivate Node front, nivate int count sublic Linkeatisto ront- count na new bdeld, front; count+ public ing size( retum count public boolean iE metyl return Icount pubievoidckar front- nuil; ount Frontnul Empty ist eturn front.setotall /Gets the first Node retum front /Scans the ist and prints the contents p-bir void enumerate Node gu- front while lcurr p bir void print venlindes Node -front break Node gu-front while lcurr u cointer at lled 3 Re-design the Node class to hold the Contact object as its data public class Nodel private String data; pvae Node nest, p bic NodelString d, Node n pabic String BedstalN return data gabic Node getNextk return nest pubie void DtaString dI data-d pubic Stringe tostrinel Finally, you will create the Adresslook class It has a Linkedlist and methods to adda contact,display al contacts, search for a specific contact and display it, or search and delete a specific contact Added contacts should be added alphabeticaly to the Linkedl ist based on their last names land then by first name in the caseof the same last names). To add alphabetically lookat the compareTo String method which compares Strings lexicographically (returns an int 0, c, or Owhich ind cates order) Displaying all the contacts should be print formatted to show results lined up eg, in columns). See the eample earch shold let users search on name, address or phone number, Searchwill find any contact where any associated instance variable eontains the target search string, and prints all matches to the console. For example, it elas is the earch target and name is the search category, then any contact where elias is the first name or last name should be displayed. Similarly, i So60 is the search taget and phone the search category, all contacts with S050 as part of their phone number should be displayed. As well, if the user searches the Street Harelope", it should return all the contacts that ive on Harslope Street. t to delete from the rfrom ? earch on name, address or phone number (ef, ereers Hansope to get a list of all contacts ?he live on Hanslope the user will be presented with ? numbered list of contacts feither with-contacts from the address book or from the search). Then the user wil select the contact from the Est to be deleted. Nhe: you ell need to deal with the situation whereuse, erters in. Certaetwth all thesame ilormaton as anexisirE Cornact. could delete hat has dplicate entries you Your AddressBookclass will look ike the UML diagrambelow + 2acotes icontact! : void //addthe giver, Costact is alphabeticalQE ?? removecontact IContact):vold Wremoves the given Contact tLht Linked.ht Nreturra the Linedixt of Contact earch [Strirg, brti : void //erter tearch word .nd tatrgory|?.E-1 for narrw. 2 for .tthen. 3 fy phone) None you canaldsupporting methods is the AddessBook if needed Imake sure you properly conent public statie void mainStringll ansk /rest of the code Youshould write a demo program that implements the AddessBook. Your complete program will have the following A short esample of output is below. The demo program should present a menu that allows the user to add a contact dsplay all contacts, search for a specific contact and display it, or search for a specific contact and delete it, and quit Your output should be nicely formatted. Below is an example screen dalog. nr 1 to seach name. 20oseachaddress 31 searth phon rown, Adar ri bo seach sane 200 seanch address inter what to seanch: Robile to earch phone n Entry to delets: Roble search 4 to dete 3 to quStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started