Resistor.java
This is the syntax highlighted version of Resistor.java
from 3.5 Inheritance of
Introduction to Computer Science by
Robert Sedgewick and Kevin Wayne.
/*************************************************************************
* 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;
}
}
Last updated: Fri Jul 16 16:41:04 EDT 2004
.
Copyright © 2004, Robert Sedgewick and Kevin Wayne.