Command Palette

Search for a command to run...

Hectal
Phase 6: Classes and Object-Oriented TypeScript
TypeScript · Exercise 3 of 6 PreviousNext
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

  1. Your code has no type errors
  2. The console prints rectangle: 6.00 and circle: 3.14
  3. Shape itself cannot be built
  4. 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.

Console

Nothing printed yet.