Question: Exercise 1. [20 points] Write a C++ program that implements the classes whose UML diagrams are given below: - Rectangle and Triangle classes should inherit
![Exercise 1. [20 points] Write a C++ program that implements the](https://s3.amazonaws.com/si.experts.images/answers/2024/09/66dc2664c8cc8_78066dc26643d931.jpg)
Exercise 1. [20 points] Write a C++ program that implements the classes whose UML diagrams are given below: - 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, get X() 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 points. - Remark: Add Square class into the design, wherever you think it's appropriate. The application that uses the classes above is coded in ShapeApp.cpp file. You normally do not need to modify this code, as well as the header files given. What you should code is a separate header (.h) and source (.cpp) file for each class so that the whole application compiles and runs, giving the following output: The instructions for the submission of the exercise is given on the next page: Zafers-MacBook-Pro:q2 zafer\$./output shapeArr[0] area(): 4 shapeArr[1] area(): 1 shapeArr[2]->area(): 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
