Public paste
switch for doubly linked lsit
By: poleXican | Date: Mar 11 2008 19:50 | Format: None | Expires: never | Size: 1.92 KB | Hits: 744

  1. import javax.swing.*;
  2. import java.awt.*;
  3. import java.util.Scanner;
  4.  
  5.  
  6.  
  7.  
  8.  
  9. public class Students
  10.  
  11. {
  12.  
  13.  
  14.   public static void main(String[] args)
  15.  
  16.  
  17.  
  18.   {
  19.  
  20.     Scanner myscanner = new Scanner(System.in);
  21.     DoublyLinkedList theList = new DoublyLinkedList();
  22.  
  23.     theList.addFront(22);
  24.     theList.addFront(44);
  25.     theList.addBack(33);
  26.     theList.addBack(55);
  27.  
  28.    // theList.display();
  29.  
  30.  
  31. int x;
  32. int choice;
  33.  
  34.           System.out.println("Press 1 to Display the list");
  35.           System.out.println("Press 2 to Add to the front");
  36.           System.out.println("Press 3 to Add to the back");
  37.           System.out.println("Press 4 to Remove from the list");
  38.           System.out.println("Press 5 Search in the list");
  39.           System.out.println("Press 6 Sort the list");
  40.           System.out.println("Press 7 update GPA");
  41.           System.out.println("Press 8 Hash Section");
  42.  
  43.  
  44.           System.out.println("What would you like to do?");
  45.           choice = myscanner.nextInt();
  46.  
  47.       switch(choice)
  48.  
  49.       {
  50.  
  51.          case 1:
  52.          theList.display();
  53.  
  54.          break;
  55.          case 2:
  56.          System.out.println("Please enter what youd like to add to the frot.");
  57.          x = myscanner.nextInt();
  58.          theList.addFront(x);
  59.          System.exit(-1);
  60.  
  61.          break;
  62.  
  63.          case 3:
  64.          System.out.println("Please enter what youd like to add to the back.");
  65.          x = myscanner.nextInt();
  66.          theList.addBack(x);
  67.  
  68.          break;
  69.  
  70.          case 4:
  71.          System.out.println("Please enter what you want to delete.");
  72.          x = myscanner.nextInt();
  73.          theList.remove(x);
  74.  
  75.          return;
  76.  
  77.          case 5:
  78.  
  79.          break;
  80.  
  81.          case 6:
  82.  
  83.          break;
  84.  
  85.          case 7:
  86.  
  87.          break;
  88.  
  89.          case 8:
  90.  
  91.          break;
  92.  
  93.          default:
  94.          System.out.println("Invalid selection.");
  95.          break;
  96. }
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.   }
  107.  
  108. }