BST Exercise


Use eclipse for this exercise.

  1. Copy all files from Shared Files, BST Exercise folder.
  2. Create a class Disk. Disk contains four fields: model (String), size (int), measure (String, for GB or TB), and performance index (int).
  3. Disk needs a constructor to initialize all fields and a toString method. Make the class Comparable and write a compareTo method that compares Disks based on the size of the disk. Make sure your comparison accounts for the fact that some numbers are in GB and some are in TB. Also write a method to create a Comparator which compares Disks based on the performance rating.
  4. Your client code should do the following:
  5. Run your program, and check that the second iterator prints the Disks in size order.
  6. Add a function that prompts for a size and prints all disks of that size. Add a call to this function at the end of main.
  7. Change main so that the BST is ordered by performance rating. Remove the call to the function that prints based on size. Run the program again and check that the second iterator prints the Disks in rating order.


Email Me | Office Hours | My Home Page | Department Home | MCC Home Page

© Copyright Emmi Schatz 2017