Reputation: 15
I have been working on a program for class that compares values of two temps. I've got everything working but on my very last method I am getting an error, even though it is built the exact same. The is not equal to function is saying required variable found value and wont run, even though the rest that are built the same way do run?
public boolean isLessThan(Temperature t){
return t.get()>this.get();
}
public boolean isGreaterThan(Temperature t){
return t.get()>this.get();
}
public boolean isEqual(Temperature t){
return (Math.abs(this.get()-t.get()))<=10E-12;
}
public boolean isGreaterThanOrEqual(Temperature t){
return t.get()>=this.get();
}
public boolean isLessThanorEqual(Temperature t){
return (t.get()<=this.get());}
public boolean isNotEqualTo(Temperature t){
return Math.abs(this.get()-t.get())=>10E-12;
}
}
Upvotes: 1
Views: 645
Reputation: 1008
Well... the operator is wrong.
<= // less or equal
>= // bigger or equal
Upvotes: 3
Reputation: 201467
Your syntax here
return Math.abs(this.get()-t.get())=>10E-12;
(assuming you want greater then or equal to) needs to be
return Math.abs(this.get()-t.get()) >= 10E-12;
Also, this
public boolean isLessThan(Temperature t){
return t.get()>this.get();
}
should be
public boolean isLessThan(Temperature t){
return t.get() < this.get();
}
Upvotes: 1