Intermediate
Finish the Abstract Shapes
Shape is an abstract class: describe() is finished and calls area(), which each subclass must provide. Rectangle and Circle forgot theirs, so the compiler complains.
Implement area() in both (a circle's area is Math.PI * r * r). The program should print rectangle: 6.00 and then circle: 3.14.
What Check tests
- Your code has no type errors
- The console prints
rectangle: 6.00andcircle: 3.14 Shapeitself cannot be built- A new subclass must implement
area
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
Runs in your browser. Your code is saved here.
Press Run to see the page.
Console
Nothing printed yet.