Question: Rectangle and Triangle classes should inherit from Shape, which only has the area ( ) method that is defined as virtual to implement polymorphism. Rectangle

Rectangle and Triangle classes should inherit from Shape, which only has the area() method that is defined as virtual to implement polymorphism. Rectangle class has two Point type members, corresponding to the upper left and lower right points of the rectangle constructed, that is, these points are expected to be supplied to the constructor of the class. Upon construction, you are advised to compute width and height of the rectangle using the getDistance(Point,Point) static method of the Point class. Triangle class has three Point members, given during the construction of the object. Similar to Rectangle, you should calculate the length of the edges of the triangle during construction. Point class is used by Rectangle and Triangle classes. Point represents a point in the Cartesian coordinate system using x and y integer distances from the origin. The class has two accessor methods, getX() and getY(), in order to allow read access to private x and y fields. Point also defines a static method getDistance(Point,Point), to calculate the distance between two given point

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!