Question: Assignment 4 C++ Course. PLEASE RUN BEFORE TO MAKE SURE IT WORKS! Write a program that creates a class hierarchy for simple geometry. (a) Start

Assignment 4 C++ Course. PLEASE RUN BEFORE TO MAKE SURE IT WORKS!

Write a program that creates a class hierarchy for simple geometry.

(a) Start with a Point class to hold x and y values of a point. Overload the operator to print point values and the + and operators to add and subtract point coordinates (hint: keep x and y separate in the calculation).

(b) Create a base class Shape that will form the basis of your shapes. The Shape class will contain functions to calculate area and circumference of the shape, plus provide the coordinates (Points) of a rectangle that encloses the shape (a bounding box). These will be overloaded by the derived classes as necessary. Create a display() function that will display the name of the class plus all stored information about the class (including area, circumference, and bounding box).

(c) Build the hierarchy by creating the Shape classes Circle, Square, and Triangle. For these derived classes, create default constructors and constructors whose arguments can initialize the shapes appropriately using the correct number of Point objects (i.e., Circle requires a Point center and a radius; Square requires four Point vertices, while Triangle requires three Point vertices).

(d) In main(), create one instance each of the following: a Circle with a radius of 23, a Square with sides 25, and a Triangle with sides 10, 20, 30. Define all of them so that the origin (0,0) is somewhere within each object. Display the information from each object.

ALSO NOTE: Someone else did answer this question but i need it redone to meet my numbers and rewriten as i dont want to get caught for copying someone elses work....here is the link

http://www.chegg.com/homework-help/questions-and-answers/write-program-creates-class-hierarchy-simple-geometry-c-1-start-point-class-hold-x-y-value-q17757354

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 Databases Questions!