public class Worker { private String name; private double rate; public Worker(String n, double r) { name = n; rate = r; } public String toString() { return name; } public double getRate() { return rate; } // Here is an alternative way to calculate worker pay based on // 2 different formulas. Instead of writing separate functions in the // subclasses, write one here, and use "instanceof" to find out which // kind of worker we have. public double computeWages(int hours) { if (this instanceof Salaried) return 40 * getRate(); else if (this instanceof Hourly) { if (hours <= 40) return hours * getRate(); else return (hours - 40) * getRate() * 1.5 + 40 * getRate(); } else return 0; } }