Define a class Shape with an abstract method CalculateArea(). Define two additional classes for a triangle and
Fantastic news! We've Found the answer you've been seeking!
Question:
Define a class Shape with an abstract method CalculateArea(). Define two additional classes for a triangle and a rectangle with fields width and height (values being set through appropriate constructors), which implement CalculateArea(). This method has to return the areas of the rectangle (height*width) and the triangle (height*width/2). Define another class for a circle with an appropriate constructor, which initializes the two fields (height and width) with the same value (the radius) and implements the abstract method for calculating the area.
Create an array of different shapes and calculate the area of each shape in another array.
Related Book For
Posted Date: