Tuesday, November 30, 2010

Lab 22 -- Driver.java -- Use this to Test


1) Remove the quotes round String and Record.

public class Driver {

 
 public static void main(String[] args) 
 {
  LinkedList<"String"> stringList = new LinkedList<"String">();
  stringList.addNodeToStart("Hello");
  stringList.addNodeToStart("Good-Bye");
  stringList.showList();
  
  System.out.println("Is 'Hello' present: " + stringList.onList("Hello"));
  System.out.println("Is 'Meeee' present: " + stringList.onList("Meeee"));
  
  System.out.println("Item Added:");
  stringList.addNodeAfterN("That Me First Time",1);
  stringList.showList();
  
  System.out.println("Item Added:");
  stringList.addNodeAfterN("That Me Second Time",2);
  stringList.showList();
  
  System.out.println("Item Added:");
  stringList.addNodeAfterN("That Me 3rd Time",4);
  stringList.showList();
  
  System.out.println("Item Deleted:");
  stringList.deleteAfterNodeN(3);
  stringList.showList();
  
  System.out.println("Item Deleted:");
  stringList.deleteAfterNodeN(3);
  stringList.showList();
  
  /* *********************************************** */
  
  System.out.println(" ************************************************* ");
  
  LinkedList<"Record"> RecordList = new LinkedList<"Record">();
  Record TomRecord = new Record("Tom", 12);
  RecordList.addNodeToStart(TomRecord);
  
  Record HarryRecord = new Record("Harry", 23);
  RecordList.addNodeToStart(HarryRecord);
  RecordList.showList();
  
  Record MyRecord = new Record("Me", 14);
  System.out.println("Is 'TomRecord' present: " + RecordList.onList(TomRecord));
  System.out.println("Is 'MyRecord' present: " + RecordList.onList(MyRecord));
  
  Record Person1 = new Record("Person1", 12);
  System.out.println("Item Added:");
  RecordList.addNodeAfterN(Person1,1);
  RecordList.showList();
  
  Record Person2 = new Record("Person2", 30);
  System.out.println("Item Added:");
  RecordList.addNodeAfterN(Person2,2);
  RecordList.showList();
  
  Record Person3 = new Record("Person3", 33);
  System.out.println("Item Added:");
  RecordList.addNodeAfterN(Person3,4);
  RecordList.showList();
  
  System.out.println("Item Deleted:");
  RecordList.deleteAfterNodeN(3);
  RecordList.showList();
  
  System.out.println("Item Deleted:");
  RecordList.deleteAfterNodeN(3);
  RecordList.showList();
  
  
 }

}

No comments: