// Film.java ========================================= class Film extends InventoryItem implements Sortable { public Film(int i, int rTemp) { super("The Film class",i); recommendedTemp = rTemp; numberOfExposures = 24; } // constructor // methods speific to Film void print() { System.out.println( getDescription() + getId() + " : " + getQuantityOnHand()); System.out.println( " recom. temp : " + recommendedTemp); } // print public int compare(Sortable b) // implements the interface { Film fm = (Film)b; // cast b to Film return recommendedTemp - fm.recommendedTemp; } // compare private int recommendedTemp; private int numberOfExposures; } // Film // InventoryItem.java ========================================= abstract class InventoryItem { public InventoryItem(String desc, int id) { description = desc; quantityOnHand = 0; inventoryNumber = id; price = 0; } // constructor abstract void print(); public String getDescription() { return description;} public String getId() { return " " + inventoryNumber + " ";} public int getQuantityOnHand() { return quantityOnHand;} public int getInventoryID() { return inventoryNumber;} public double getPrice() { return price;} private String description; private int quantityOnHand; private int inventoryNumber; private double price; } // class InventoryItem // Sort.java ========================================= import java.util.*; public class Sort { public static void sort(Vector a) { int k; int n = a.size(); k = 0; while (k < n) { int j = getSmallest(a, k); exchange(a, k, j); k ++; } // while } // Sort static void exchange(Vector a, int k, int j) { Object temp; temp = a.elementAt(k); a.setElementAt(a.elementAt(j), k); a.setElementAt(temp, j); } // exchange static int getSmallest(Vector a, int k) { Sortable s = (Sortable)a.elementAt(k); int n = a.size(); int minLoc = k; for (int i = k; i < n; i ++) if (s.compare((Sortable)a.elementAt(i)) > 0) // s > a[i] { s = (Sortable)a.elementAt(i); minLoc = i; } return minLoc; } // getSmallest } // Sort // Sortable.java ========================================= public interface Sortable { public abstract int compare(Sortable b); // child class will implement it }