+ 1
Java: Shapes project - what's the difference in a formula?
I'm doing the Shapes Project in Java and I've noticed that one of the Tests fails. My first code contained public class Circle extends Shape{ Circle (int y) { this.width = y; } void area(){ System.out.println(Math.PI*width*width); } } After reflecting on my long lost high school maths, I thought that this code could solve that: public class Circle extends Shape{ Circle (int y) { this.width = y; } void area(){ int r = width*width; System.out.println(Math.PI*r); } } Both pass Tests 1, 2 & 4. The first code fails Test 5, the second code fails Test 3. What am I missing?
3 ответов
+ 2
What does your Square class look like?
Can you please put your complete code on playground and attach it here?
edit:
sometimes re-running the code helps if sololearn is buggy
+ 1
Your edit rings true. After posting this, I re-ran the code and it all turned green.
+ 1
Happens sometimes :)