Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Implement a class named Circle that has the following (and only the following): Data members for storing the x, y and radius (where x,y

C++

image text in transcribed

image text in transcribed

Implement a class named Circle that has the following (and only the following): Data members for storing the x, y and radius (where x,y are the position of the circle on x,y coordinates). The data members X.X must be of type int while radius should be float. Any constructor that allow users to define objects of type Circle in any of the following ways: Circle c1; // the circle is initialized to radius=1,x=0, y=0 Circle c2(3); // the circle is initialized to radius=3,x=0, y=0 Circle c3(10, 3); // the circle is initialized to radius=10,x=3, y=0 Circle c4(10, 5, 7); // the circle is initialized to radius=10,x=5,y=7 The constructor(s) must validate the received arguments as follows: X are allowed to be in the range [-100, 100] Y are allowed to be in the range [, 200] Radius are allowed to be in the range (1, 50] If a received x or y is invalid, the constructor should output an error message and set it to 0. While radius should be set to 1 for invalid value. Getter functions for the x, y and radius. Function void print() that prints the cirlcle info as radius->(x,y) Examples: 2->(0,0) 15->(3,5) Function void up) that increment y by 1. o If y reaches 201, reset y to Function void down() that decrements y by 1. o If y reaches - 1. reset y to 200 Function void right that increment x by 1. 0 If x reaches 101, reset x to - 100 Function void left() that decrements x by 1. If x reaches -101, reset x to 100 The following functions for changing the circle: o void update_radius (int ds) // update the radius by ds (can be - or +), you should not accept the change if radius becomes outside its range obool isUnit() //check if the circle is a circle of unit radius-that is, a radius of 1 o void move_y(int m) // moves the circle by m on the y-axis o void move_x (int h) // moves the circle by h on the x-axis. ! Hint: You can make use of up() and down() in your implementation of move y function. While left and right() can be used for move u functions. ! Note. Regardless of how you implement these functions, make sure that all data members never becomes invalid. ! Done early? Think of another way for implementing the move_x and move_y functions that does not involve using the up, down, left, right functions and does not involve using loops

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

Pro Oracle Fusion Applications Installation And Administration

Authors: Tushar Thakker

1st Edition

1484209834, 9781484209837

More Books

Students also viewed these Databases questions