21st Jul 2022, 4:10 AM
Ahmed Kazia
Ahmed Kazia - avatar
1 Answer
+ 3
First, your implementations must be different, the calculation for the circle is wrong. Then remove these lines: Area = area; area = rect; area = cir; And get directly your variables rect and circ in the println. Good practice : we often try to instantiate the object by declaring the most abstract parent : Area cir = new Circle() Area rect = new Rectangle() It allows to have for example a list of Areas or a method waiting for an Area whatever the implementation
21st Jul 2022, 5:18 AM
Roland
Roland - avatar