Extend the “Circle” class to have the following features. Two additional data members (integers) to store the x and y coordinate of the center of the Circle. A parameterized constructor. Set() and Get() methods for each of the data members. A function to display the data members of the class. A function enlargeCirlce(int); which increases the radius of the circle by the factor passed as input to the For example, if “c” is an object of class Circle, the statement c.enlargeCircle(2); should double the radius of the circle. A function moveHorizontal(int); which should move the center of the circle in the horizontal direction. For example, if “c” is a circle with center at (5,10), moveHorizontal(3); should move the center to position (8,10). A fuction moveVertical(int); similar to the moveHorizontal(int); function.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Task 1:

Extend the “Circle” class to have the following features.

  1. Two additional data members (integers) to store the x and y coordinate of the center of the Circle.
  2. A parameterized constructor.
  3. Set() and Get() methods for each of the data members.
  4. A function to display the data members of the class.
  5. A function enlargeCirlce(int); which increases the radius of the circle by the factor passed as input to the For example, if “c” is an object of class Circle, the statement c.enlargeCircle(2); should double the radius of the circle.
  6. A function moveHorizontal(int); which should move the center of the circle in the horizontal direction. For example, if “c” is a circle with center at (5,10), moveHorizontal(3); should move the center to position (8,10).
  7. A fuction moveVertical(int); similar to the moveHorizontal(int); function.

In the main program, create two objects of class Circle. Find which of the two circles is smaller (by comparing their radii) and enlarge the smaller circle by a factor of 2.

Code:

#include<iostream>
using namespace std;
  

//Class which holds properties and methods of a class
class Circle {
private:
    int radius;
public:

    //Parameterized constructor that creates an object
    Circle(int r=0)  {radius=r;}
      

    //Member function to find area
    int area(){
        return 22*radius*radius/7;
    }
    

    //Member function to find circumference
    int circumference(){
        return 2*22*radius/7;
    }
    

    //Member function to print results
    void print(int ar, int cf)
    {
        cout<<"Area of circle with radius "<<radius<<" is "<<ar<<" and circumference of circle is "<<cf<<endl;
    }
};
  
int main()
{
    Circle c1(49),c2(61);     //Creating two objects of class circle
    
    int ar1=c1.area();
    int cf1=c1.circumference();
    c1.print(ar1,cf1);
    
    int ar2=c2.area();
    int cf2=c2.circumference();
    c2.print(ar2,cf2);
    
    return 0;
}

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education