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–2022, Robert Sedgewick and Kevin Wayne.
Last updated: Thu Aug 11 10:27:28 EDT 2022.