Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How do you start the program? with the given Node.java file and the Table.java file. import java.util.Scanner; public class AddressBook { public static void main(String[]

How do you start the program? with the given Node.java file and the Table.java file.

import java.util.Scanner;

public class AddressBook { public static void main(String[] args){ // Here, you should be able to start your program } }

public class Node { private String key; private String value; private Node next;

Node() { // add here .. }

Node(String key, String value) { // add here .. this.key = key; this.value = value; this.next = null; }

public String getKey() { // add here .. return this.key; }

public void setKey(String key) { // add here .. this.key = key; }

public String getValue() { // add here .. return this.value; }

public void setValue(String value) { // add here .. this.value = value; }

public Node getNext() { // add here .. return this.next; }

public void setNext(Node next) { // add here .. this.next = next; } }

import java.util.Scanner;

import org.w3c.dom.Node;

public class Table {

private Node mark;

public Node getMark() { // Add here return this.mark; }

public void setMark(Node mark) { // Add here this.mark = mark; }

public boolean insert(String key, String value) { // Add here Node newNode = new Node(key, value); if (this.mark == null) { this.mark = newNode; } else { newNode.setNext(this.mark.getNext()); this.mark.setNext(newNode); } return true; }

public String lookUp(String key) { // Add here Node current = this.mark; while (current != null) { if(current.getKey().equals(key)) { return current.getValue(); } current = current.getNext(); } return null; }

public boolean delete(String key) { // Add here Node current = this.mark; Node prev = null; while (current != null) { if (current.getKey().equals(key)) { if (prev == null) { this.mark = current.getNext(); }else { prev.setNext(current.getNext()); } return true; } prev = current; current = current.getNext(); } return false;

}

public boolean update(String key, String newValue) { // Add here Node current = this.mark; while (current != null) { if (current.getKey().equals(key)) { current.setValue(newValue); return true; } current = current.getNext(); } return false; }

public boolean markToStart() { // Add here if (this.mark == null) { return false; } this.mark = null; return true; }

public boolean advanceMark() { // Add here if (this.mark == null) { return false; } this.mark = this.mark.getNext(); return true; }

public String keyAtMark() { // Add here if (this.mark == null) { return null; } return this.mark.getKey(); }

public String valueAtMark() { // Add here if (this.mark == null) { return null; } return this.mark.getValue(); }

public int displayAll() { // Add here Node current = this.mark; int count = 0; while (current != null) { System.out.println(current.getKey() + ":" + current) }

} }

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

Pro Database Migration To Azure Data Modernization For The Enterprise

Authors: Kevin Kline, Denis McDowell, Dustin Dorsey, Matt Gordon

1st Edition

1484282299, 978-1484282298

More Books

Students also viewed these Databases questions