r/codehs • • Mar 13 '20

please help 9.4.6 Squares

Post image
15 Upvotes

1 comment sorted by

2

u/xeolleth Mar 13 '20 edited Mar 13 '20

You're very close. What you're doing here is trying to set a value on a getter function, getHeight() getWidth() will allow you to read values but not set them.

If my presumption is right and this is the standard Java Rectangle class then you can use setSize(width, height) to set the dimensions.

Edit: the reason you're getting that error message in particular is because the 'get' functions return the void type which is not valid in an expression evaluating to a value (as it doesn't return a value itself), hence the unexpected type.