You are given the following classes:
class Shape {
}
class Square extends Shape {
private int side;
public int getSide() {
return side;
}
public void setSide(int side) {
this.side = side;
}
}
class Rectangle extends Shape {
private int width, height;
public int getWidth() {
return width;
}
public void setWidth(int width) {
this.width = width;
}
public int getHeight() {
return height;
}
public void setHeight(int height) {
this.height = height;
}
}
Unfortunately, the author of this class hierarchy forgot to add the getArea() method to these classes. Now you need to implement a method that calculates the sum of areas of the Shape array. If some elements are instances of the class Shape, their area equals 0.