CSC 17 Lab 6. Due next Thursday (start of lab) 1. Finish Lab 5. On the class homepage there are code for quicksort on an array of doubles. There is also a program that creates a heap of doubles. Both programs can be made polymorphic. I did one in class. You should do the other. Be aware that Java doesn't allow you to initialize a generic array. That is, the following code would not compile: class yourclass { Ty[] H; // array of type Ty to be set by constructor yourclass(int size) //constructor { H = new Ty[size]; } // compiler error here. can't create generic array } You need to know the exact type before creating an array. So the constructor should be written this way instead: yourclass(Ty[] A) { H = A; } This means that the array must be created externally to the class. That is, you pass the ready-made array to the constructor: yourclass M; String[] S = new String[100]; // an array of strings M = new yourclass(S); // M.H is now set to the array S. -------- 2. Consider the following, rather "boring" class for a student record: class student { String name; // name of student int id; // 700 number double gpa = 2.0; // gpa String major = "computer science" int year = 0; // 0 = freshman, 3 = senior public student(String n, int i) {name=n; id=i;} // constructor } For a student to be inserted into a polymorphic heap, you need to make the student class implement Comparable. You may sort the students by their name (alphabetically), by their 700 number, or by their gpa. Re-write the student class to effect this, and demonstrate how to insert/deletemax student records from a heap of student records: class student implements Comparable ... 3. This problem asks you to try and devise a solution yourself. Clearly it is possible to sort student records using multiple means (by name, by gpa, etc ...). How would you make your program flexible enough so that student records can be ordered in more than one way. That is, how would you accomodate more than one version of the "comparable" function in your program? Describe you solution with as much detail as possible (will discuss in class later).