Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Databases In Networked Information Systems 6th International Workshop Dnis 2010 Aizu Wakamatsu Japan March 2010 Proceedings Lncs 5999

Authors: Shinji Kikuchi ,Shelly Sachdeva ,Subhash Bhalla

2010th Edition

3642120377, 978-3642120374

More Books

Students also viewed these Databases questions

Question

4. What action should Cherita Howard take and why?

Answered: 1 week ago