Advertisement
Guest User

Untitled

a guest
May 19th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. import java.util.*;
  2. public class IntegerListTest
  3. {
  4. static IntegerList list = new IntegerList(10);
  5. static Scanner scan = new Scanner (System.in);
  6.  
  7. public static void main (String[] args)
  8. {
  9. printMenu();
  10. int choice = scan.nextInt();
  11. while (choice != 0)
  12. {
  13. dispatch (choice);
  14. printMenu ();
  15. choice = scan.nextInt();
  16. }
  17. }
  18.  
  19. public static void dispatch (int choice)
  20. {
  21. int loc;
  22. switch (choice)
  23. {
  24. case 0:
  25. System.out.println ("Bye!");
  26. break;
  27. case 1:
  28. System.out.println ("How big should the list be?");
  29. int size = scan.nextInt();
  30. list = new IntegerList (size);
  31. list.randomize();
  32. break;
  33. case 2:
  34. list.print();
  35. break;
  36. default:
  37. System.out.println ("Sorry, invalid choice");
  38. }
  39. }
  40.  
  41. public static void printMenu()
  42. {
  43. System.out.println ("\n Menu ");
  44. System.out.println (" ====");
  45. System.out.println ("0: Quit");
  46. System.out.println ("1: Create a new list (** do this first!! **)");
  47. System.out.println ("2: Print the list");
  48. System.out.println ("\nEnter your choice: ");
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement