Skip to main content

Practice ยท 1 of 2

Polymorphic shapes

Inside Solution, write static abstract class Shape with abstract double area() and String name(); plus static class Circle extends Shape (constructor takes radius), static class Rect extends Shape (width, height). Implement static double totalArea(Shape[] shapes) that works for ANY mix of shapes.

Difficulty: beginner

Back to lesson: Practice: Practice: Designing with Polymorphism