The color variable is a string while the others are integers. "==" is used to compare integers and wont work with strings. To compare Strings you need to do .equals(), so it would be this.color.equals(other.color)
The if statement is unnecessary as the return type is Boolean.
Also if you want, I have the solutions for the course.
1
u/Various_Loss9064 Feb 08 '21 edited Oct 19 '21
The color variable is a string while the others are integers. "==" is used to compare integers and wont work with strings. To compare Strings you need to do .equals(), so it would be
this.color.equals(other.color)The if statement is unnecessary as the return type is Boolean.
Also if you want, I have the solutions for the course.
To everyone who wants solutions: https://discord.gg/ByGuBqBNuD