/*

* To change this template, choose Tools | Templates

* and open the template in the editor.

*/

Main File

public class Main { public static void main(String[] args){ LibraryLab5 t = new LibraryLab5(); LibraryLab5 p = new LibraryLab5(); System.out.println("T: " + t.toString()); System.out.println("t2: " + t.toString()); System.out.println("T3: " + t.toString()); LibraryLab5 []list = Time.getRandomArrayofTimes(); Time.printArrayofTimes(list); System.out.println(); LibraryLab5 [] tArray = Time.getRandomArrayofTimes(); Time.displayArrayToScreen(tArray); Time.doFillArray(); LibraryLab5.quickSort(); Time.printArrayofTimes(tArray); System.out.println(); if(list.compareTo(tArray) > 0) System.out.println("t is Greater"); else if(list.compareTo(tArray) < 0) System.out.println("t is smaller"); else System.out.println("They are the same"); } }

Time File

import java.util.*; public class Time{ public LibraryLab5 pink; static int tArray; public static LibraryLab5 [] getRandomArrayofTimes(){ LibraryLab5 [] tArray = new LibraryLab5 [10]; Random rand = new Random(System.currentTimeMillis()); for(int i = 0; i < 10; i++){ int k = rand.nextInt(999999999); LibraryLab5 pink = new LibraryLab5(k); tArray[i] = pink; } return tArray; } public static int[] doFillArray() { int[] list = new int [12]; Random rand = new Random(System.currentTimeMillis()); for (int i = 0; i < 12; ++i) { int k = rand.nextInt(999999999); } return list; } public static <E> void displayArrayToScreen(E [] displayArray){ System.out.println("The array contents are: "); for(int i = 0; i < displayArray.length; ++i ){ System.out.println(displayArray[i]); } } public static void printArrayofTimes(LibraryLab5[] Array){ for(int i = 0; i < Array.length; i++){ System.out.println("Random Array: " + i + Array[i]); } } }

My Library

import java.util.Random; import java.util.*; public class LibraryLab5{ //implements Comparable private int minute; private int second; private int hour; public LibraryLab5(){ this(System.currentTimeMillis()); } public LibraryLab5(long elaspedTime) { long totalSeconds = elaspedTime / 1000L; this.second = (int)(totalSeconds % 60L); long totalMinutes = totalSeconds / 60L; this.minute = (int)(totalMinutes % 60L); int totalHours = (int)(totalMinutes/ 60L); this.hour = (totalHours % 24); } //muators public long getSeconds(){ return second; } public long getMinutes(){ return minute; } public long getHours(){ return hour; } public static void quickSort(int [] Array){ quickSort(Array, 0, Array.length - 1); } private static void quickSort(int [] Array, int first, int last){ if(last > first){ int pivotIndex = partition(Array, first, last); quickSort(Array, first, pivotIndex - 1); quickSort(Array, pivotIndex + 1, last ); } } private static int partition(int [] list, int first, int last){ int pivot = list[first]; int low = first + 1; int high = last; while(high > low){ while(low <= high && list[low] <= pivot) low++; while(low <= high && list[high] > pivot) high--; if(high > low){ int temp = list[high]; list[high] = list[low]; list[low] = temp; } } while(high > first && list[high]>= pivot) high--; if(pivot > list[high]){ list[first] = list[high]; list[high] = pivot; return high; } else{ return first; } } public void displayTime(long totalHours, long totalMinutes, long totalSeconds){ for(int i = 0; i < totalHours; i++){ for(int j = 0; j< totalMinutes; j++){ for(int k = 0; k < totalSeconds; k++){ } System.out.print(hour + minute + second); } System.out.println(); } } public double sumOfSquares(){ double sum = 0; for(int i = 0; i < hour ; i++){ for(int j = 0; j < second; j++){ for(int g = 0; g < minute; g++) { sum += hour * minute * second; } } } return sum; } public int compareTo(Object M){ //read compareTo method in text if(sumOfSquares() > ((LibraryLab5)M).sumOfSquares()) return 1; else if(sumOfSquares() < ((LibraryLab5)M).sumOfSquares()) return -1; else return 0; } public String toString(){ String s; s = hour + " : " + minute + ": " + second + " GMT"; return s; } }

What I am trying to do is compare the random array of times, and sort it... but it's giving me errors, please help me.