Advertisement
Guest User

Untitled

a guest
Nov 18th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.65 KB | None | 0 0
  1. package binarysearchtreeassignmentcosc311;
  2.  
  3. import java.util.*;
  4.  
  5. public class BinarySearchTreeAssignmentCOSC311 {
  6.  
  7.     public static void main(String[] args) {
  8.         /*The following declaration declares a data structure that will change from one assignment to the next. For example, you will need to implement
  9.          * the following as a doubly linked list, as well as a tree.
  10.          */
  11.  
  12.         Database d = new Database();
  13.         int response;
  14.         Scanner keyboard = new Scanner(System.in);
  15.  
  16.         /* Read the data into the database from the external disk file here
  17.          * IMPORTANT: duplicate ID numbers should not be added. Disregard
  18.          * the entire record for duplicate IDs
  19.          */
  20.         do {
  21.             System.out.println(" 1 Add a new student");
  22.             System.out.println(" 2 Delete a student");
  23.             System.out.println(" 3 Find a student by ID");
  24.             System.out.println(" 4 List students by ID increasing");
  25.             System.out.println(" 5 List students by first name increasing");
  26.             System.out.println(" 6 List students by last name increasing");
  27.             System.out.println(" 7 List students by ID decreasing");
  28.             System.out.println(" 8 List students by first name decreasing");
  29.             System.out.println(" 9 List students by last name decreasing");
  30.             System.out.println(" ");
  31.             System.out.println(" 0 End");
  32.  
  33.             response = keyboard.nextInt();
  34.  
  35.             switch (response) {
  36.                 case 1:
  37.                     d.addIt();  //Note: if the user enters an ID already in use, issue a warning and return to the menu
  38.                     break;
  39.                 case 2:
  40.                     d.deleteIt();   //Note: output either "Deleted" or "ID not Found" and return to menu
  41.                     break;
  42.                 case 3:
  43.                     d.findIt(); //Note: output the entire record or the message "ID not Found" and return to menu
  44.                     break;
  45.                 case 4:
  46.                     d.ListByIDAscending();
  47.                     break;
  48.                 case 5:
  49.                     d.ListByFirstAscending();
  50.                     break;
  51.                 case 6:
  52.                     d.ListByLastAscending();
  53.                     break;
  54.                 case 7:
  55.                     d.ListByIDDescending();
  56.                     break;
  57.                 case 8:
  58.                     d.ListByFirstDescending();
  59.                     break;
  60.                 case 9:
  61.                     d.ListByLastDescending();
  62.                     break;
  63.                 default:
  64.             }
  65.  
  66.         } while (response != 0);
  67.     }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement