Question
Implement LLAddressBook.java using array(s). Instead of using Linked Lists, you will use arrays. You can use any approach, however, you must store the data in
Implement LLAddressBook.java using array(s). Instead of using Linked Lists, you will use arrays. You can use any approach, however, you must store the data in array(s).
Hint: You can use three different arrays for firstName, lastName and phoneNumber. Index numbers of an entry in each array would be the same.
The LLAddressBook.Java is below.
package cs260_02122020;
public class LLAddressBook {
//data members private AddressNode log; private String name; //constructors public LLAddressBook(String initFirstName, String initLastName, String initPhoneNumber, String initName) { //create a new addressNode with given parameters log = new AddressNode(initFirstName, initLastName, initPhoneNumber); name = initName; } //methods public String toString() { String result = ""; AddressNode currNode; currNode = log; //go into the loop to collect strings... while (currNode != null) { result += currNode.toString() + ' '; currNode = currNode.getNextNode(); } return name + ": " + result; } //insert method public void insert(String newLastName, String newFirstName, String newPhoneNumber) { //step 1: create a new node AddressNode newNode = new AddressNode( newLastName, newFirstName, newPhoneNumber); //step 2: set its nextNode to log newNode.setNextNode(log); //step 3: set log to this newNode (last step!) log = newNode; } public void clear() { log = null; } //searching by the lastName public boolean search(String targetLastName) { AddressNode currNode; currNode = log;//start from the first noed boolean result = false; while (currNode != null) { if(targetLastName.equalsIgnoreCase(currNode.getLastName())) { return true; } currNode = currNode.getNextNode(); } return false; } }
Thing is theres a whole folder of code that was given to me along with the assignment so I cant upload it all here since it would be a lot. If anyone can please help me answer this question, id be able to send the file to you if you reply to me with a contact.
Step 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