Question
C++ Language In this assignment, you will create a class that can behave as any of the shapes listed below. You will use object inheritance
C++ Language
In this assignment, you will create a class that can behave as any of the shapes listed below. You will use object inheritance to enable all shapes to be managed using the same interface. The functions named in your interface file will be polymorphic; they behave differently depending on the instance of a shape is being emulated by an object.
Using the combination of inheritance and function overloading, you will design a program that can manipulate a group of objects derived from the base class Shape. A Shape is an abstract class that can be used to represent instances of the following geometric shapes:
A Triangle
A Rectangle
A Square
An Oval
A Circle
An Elliipse
Your program should contain classes to create each type of object listed above. You should design an inheritance hierarchy where all classes are derived from an abstract class called Shape. The shape class should have a virtual function getArea() that when invoked on an object will return the area of that shape object. You should insert the code from the GeometricArea program for the appropriate type of shape object. Here is a guide to calculating the area of an ellipse and how it relates to a circle.
Your program should make use of a concrete class named Point. Point has two fields of type float: x and y representing a Cartesian coordinate that identifies a location in the xy plane. Each shape should contain the necessary fields to represent itself: for example, a triangle would contain 3 Point objects, a circle 1 Point.
Be sure to consider using intermediate classes. For example, Triangle, Rectangle, Square are all polygons, so it is good design practice to create an intermediate class Polygon, from which Triangle, Rectangle and Square are all derived. There is a similar relationship between an ellipse and a circle; a circle is an ellipse where the two focal points are the same and the length of the major and minor radii are the same.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started