So at the moment, I've managed to create a getter method with the following code
public int getDivisor() {
return this.divisor;
}
That will return 2.
I'm stuck on creating a setter method for my project. The question is: Write a public setter method for divisor, which sets divisor to the value of the argument. It cannot be 0, really am stuck on this question. Can anybody help, please? Much appreciated.
I have now added the following method
public void setValue(int number) {
if (number == 0)
this.divisor = number;
}
for the setter message.
After entering a message divisor.SetValue();
it comes back the error cannot find symbol - method SetValue(). Am I doing something wrong?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…