Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise 1. [20 points] Write a C++ program that implements the classes whose UML diagrams are given below: - Rectangle and Triangle classes should inherit

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Sham Navathe

4th Edition

0321122267, 978-0321122261

More Books

Students also viewed these Databases questions

Question

Explain the various techniques of Management Development.

Answered: 1 week ago