
/**
 * Models a resistor with resistance and power
 * dissipation attributes.
 *
 * @author Rod Byrne
 * @version 0.1
 * @since October 17, 2004
 */
public class Resistor implements Comparable<Resistor> {

    private double resistance; // in ohms
    private double powerDissipation; // in watts

    public Resistor( double res, double power ) {
        this.resistance = res;
        this.powerDissipation = power;
    }

    public double getResistance() {
        return resistance;
    }

    public double getPowerDissipation() {
        return powerDissipation;
    }

    public String toString() {
        return resistance + " " + powerDissipation;
    }

    public int compareTo( Resistor r ) {
        if ( resistance < r.resistance ) {
            return -1;
        }
        else if ( resistance > r.resistance ) {
            return 1;
        }
        else {
            return 0;
        }
    }
}
