Home
Site Map
Useful Tools
Graphing Calc

Scientific Calculator

Why Interfaces Are Useful

We are going to write a class that sorts some of the classes we have already written --namely : the Account and Student classes that we wrote in the past. Specifically, this class is going to sort students and accounts by their grade point averages and their account balances , respectively..
Organizer Skeleton class (You only have to fill in 1 method)

Class : Organizer

The Constructor
  • The constructor is completely written for you already. It creates an array of Accounts and an array of Students . It also sends the arrays to both of the sort methods described below. You only need to write 1 method : public static void sort (Student[] arr) which is described below.
Accessor Methods
  • Sort Methods
    • public static void sort(Account[] arr)// Implemented this for you
    • public static void sort (Student[] arr) //basically...modify the sort method above so that it works for the Student class by comparing their cumulative average (ie getCumulativeAverage() ;

What if we wanted to sort the School class and add the method void sort(School[] schools)?

Answer: We'd have to yet again add a whole new method that is very similar to the two sort methods we already wrote.

Sitemap