0

[Solved] Why doesn’t this work?

Stuck on the Java tutorial again. Tried for another hour. —— Update: Solved. https://code.sololearn.com/cmolYYqimeap/?ref=app

8th Feb 2022, 8:47 AM
Albert Tan
4 Answers
+ 4
Albert Tan Check the abstract method in Abstract class which has void return type not int or double. And also constructors should have 1 argument which is area. class Square extends Shape { Square(int w) { this.setWidth(w); } void area() { int area = width*width; System.out.println(area); } public void setWidth(int w) { this.width = w; } } class Circle extends Shape { Circle(int w) { this.setWidth(w); } void area() { double area = Math.PI * width * width; System.out.println(area); } public void setWidth(int w) { this.width = w; } }
8th Feb 2022, 9:00 AM
A͢J
A͢J - avatar
+ 2
Thanks!!
8th Feb 2022, 9:54 AM
Albert Tan
+ 1
Albert Tan Change this width * Math.PI * 2 To Math.PI * width * width
8th Feb 2022, 8:50 AM
A͢J
A͢J - avatar
+ 1
Albert Tan Area of circle is PI * r * r Perimeter of circle is 2 * PI * r
8th Feb 2022, 8:53 AM
A͢J
A͢J - avatar