Question: The getResistance ( ) method you are given is: public double getResistance ( ) { return 0 . 0 ; } 2 . You need
The getResistancemethod you are given is:
public double getResistance
return ;
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.
You have to declare this instance variable it should have private visibility and be of
type double.
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;
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.
You have to initialize its value in the constructor and use its value in the
getResistance method. Note that the constructor is declared:
public Resistordouble resistance
The value of the Resistor object to be created is given by the resistance
parameter.
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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
