Question: The getResistance ( ) method you are given is: public double getResistance ( ) { return 0 . 0 ; } 2 . You need

The getResistance()method you are given is:
public double getResistance(){
return 0.0;
}
2. You need to have it return the actual value of the Resistor's resistance. This should
be an instance (or state) variable of a Resistor object.
3. You have to declare this instance variable (it should have private visibility and be of
type double.)
4. Of course you also have to choose a name for it. The name should be descriptive of
its meaning. For example, this is a very poor choice (although it would be legal) :
private double guessWhatIam;
1. However, do not use the name resistance. (You will soon learn why; you will
also learn how you can use this name but it requires a little bit more Java
knowledge.)
2. You have to initialize its value in the constructor and use its value in the
getResistance() method. Note that the constructor is declared:
public Resistor(double resistance){
3. The value of the Resistor object to be created is given by the resistance
parameter.
4. You simply have to assign this parameter to whatever name you have chosen as the
object's instance variable.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!