java - How to calculate area of child class from parent class -
here questions: when i'm printing area of both shapes, getting correct area ellipse , 0 circles . why? i have multiple radii of circle. how can keep on adding area, computed previous radius? in short, need sum area of radii. whenever pass radius of circle, need circle area (computed radius) should added ellipse area well. how that? this current code: public class ellipse { private double area; private double axis1; private double axis2; public ellipse() { area = 0; } public ellipse (double axis1, double axis2) { this.axis1 = axis1; this.axis2 = axis2; } public void calculatearea() { area += axis1 * axis2; } public double getarea() { return area; } } public class circle extends ellipse { private double radius; private double area; public circle(){ area = 0; } public circle(double radius) { super(radius, radius); } public double get