public class LLNode{    private Name name;    private LLNode next;    public LLNode(){       name=null;       next=null;    }    public LLNode(Name name, LLNode next){       setName(name);        setNext(next);     }    public Name getName(){       return name;    }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

public class LLNode{

   private Name name;
   private LLNode next;
   public LLNode(){
      name=null;
      next=null;
   }
   public LLNode(Name name, LLNode next){
      setName(name); 
      setNext(next); 
   }

   public Name getName(){
      return name;
   }
   public LLNode getNext(){
      return next;
   }
   public void setName(Name name){
      this.name = name;
   }
   public void setNext(LLNode next){
      this.next = next;
   }
   

}

******************************************************************
public class Name implements Comparable<Name>{

   private String firstName;
   private String lastName;
   public Name(String firstName, String lastName){
      setFirstName(firstName); 
      setLastName(lastName); 
   }

   public String getFirstName(){
      return firstName;
   }
   public String getLastName(){
      return lastName;
   }
   public void setFirstName(String firstName){
      this.firstName = firstName;
   }
   public void setLastName(String lastName){
      this.lastName = lastName;
   }
   @Override
  public int compareTo(Name n){
      String lastA = lastName.toUpperCase();
      String firstA = firstName.toUpperCase();
      String lastB = n.getLastName().toUpperCase();
      String firstB = n.getFirstName().toUpperCase();
      if(lastA.compareTo(lastB)==0){
         return firstA.compareTo(firstB);
      }
      return lastA.compareTo(lastB);
   }
   @Override
  public String toString(){
      return String.format("%15s%15s", firstName, lastName);
   }
}

 

******************************************************************

public class SortedNameList{
   LLNode head;
   public SortedNameList(){
      head=null;
   }
   public LLNode getHead(){
      return head;
   }
   
   public boolean isEmpty(){
      //return true if the list is empty, otherwise true
      /* Type your code here. */
      
      
   }
   
   public void add(Name name){
      //add name to the list, after this operation, the list should maintain sorted in ascending order
      /* Type your code here. */
      
   }
     
   public void add(LLNode node){
      //overloaded method: add node to the list, after this operation, the list should maintain sorted in ascending order
      /* Type your code here. */
   }
   public int size(){
      //return the number of nodes in the list
      /* Type your code here. */
      
      return 0; // replace with yours
   }
   
   public boolean isFull(){
      return false;
   }

   public int search(Name name){
      //return index of the name (the first occurrence) in the list, return -1 if not found
      /* Type your code here. */
      
      return -10; // replace with yours
   }
   public LLNode get(int index){
      // return the LLNode object at the specified index location, for invalid index, return null
      /* Type your code here. */
      
      return new LLNode(new Name("a","b"), null); //replace with yours
   }
   public void remove(int index){
      //Remove node at the specified index location if valid.
      /* Type your code here. */
      
   }
   public void remove(Name name){
      //remove all occurences of name - please refer to Name class for details
      /* Type your code here. */
   } 
   public void removeAll(){
      //remove all nodes
   }
}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education