Resistor.java


Below is the syntax highlighted version of Resistor.java from §3.6 Case Study: Purple America.


/******************************************************************************
 *  Compilation:  javac Resistor.java
 *  Execution:    java Resistor
 *
 ******************************************************************************/

public class Resistor extends Circuit {
    private double resistance;
    private double potentialDiff;
        
    public Resistor(double r) {
        resistance = r;
    }

    public double getResistance() {
        return resistance;
    }
        
    public double getPotentialDiff() {
        return potentialDiff;
    }
        
    public void applyPotentialDiff(double V) {
        potentialDiff = V;
    }
}


Copyright © 2000–2017, Robert Sedgewick and Kevin Wayne.
Last updated: Fri Oct 20 14:12:12 EDT 2017.