Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(a) [15 Points] Shape class: Create a base class representing a shape. [-] two private ints (to designate the location of the object), and name

image text in transcribed

(a) [15 Points] Shape class: Create a base class representing a shape. [-] two private ints (to designate the location of the object), and name them x and y. [+] implement a single constructor such that if called with two arguments x and y, creates a Shape located at (x,y). Support the following four operations using the given function signatures: [+] Get the x coordinate, [+] Get the y coordinate [+] Set the x coordinate, [+] Set the y coordinate [+] Implement a method called MoveShape with two arguments xnew and ynew such that location of the shape is updated with the inputs arguments. [+] implement a method to displace a Shape with two arguments x and y such that location of the shape is updated with x+x and y+y, respectively. [+] two virtual functions to draw Shape (see the sample runs) and to compute and return area of the shape. (b) [15 Points] Rectangle class: Create a derived class representing a rectangle. [-] two private ints (to designate the width and height of the object). [+] implement a single constructor that, if called with 0 arguments, initializes a unit Rectangle at the origin (0,0) and width = height =1, but if called with four arguments x,y,w,h, creates a Rectangle located at (x,y) with (width, height) = (w,h). (Hint: You will need to use default arguments.) Support the following operations using the given function signatures: [+] Get width, [+] Get height, [+] Set width, [+] Set height [+] implement draw Shape function for Rectangle. [+] implement area function for Rectangle that returns the area of the object. (c) [15 Points ] Circle class: Create a derived class representing a circle. [-] one private ints (to designate the radius of the circle). [+] implement a single constructor that, if called with 0 arguments, initializes a unit Circle at the origin (0,0) and radius =1, but if called with three arguments x,y,r, creates a Circle located at (x,y) with (radius =r ). Support the following operations using the given function signatures: [+] Get radius, [+] Set radius [+] implement draw Shape function for Circle [+] implement area function for Circle that return the area of the object. Using the provided q2_TestShape.cpp code to test your classes defined above with the defined properties. You don't need to modify or upload q2_TestShape.cpp. However, your program will be tested with other sets of inputs. See the sample run below. 5 [Zafers-MacBook-Pro:qe3 zafer $./shapeApp Drawing a Rectangle at:(10,20), width 5 , height 6 Drawing a Rectangle at:(110,120), width 5 , height 6 shape_area: 30 Drawing a Circle at: (15,25), radius 8 Drawing a Circle at: (115,125), radius 8 shape_area: 201.056 Drawing a Rectangle at:(0,0), width 1 , height 1 Drawing a Rectangle at:(100,100), width 1, height 1 shape_area: 1 Drawing a Circle at:(100,100), radius 1 shape_area: 3.1415

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

Students also viewed these Databases questions