Advertisement
AntoniiaG

Point

Jan 29th, 2023 (edited)
744
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.09 KB | Source Code | 0 0
  1. // pointCircle.cpp : This file contains the 'main' function. Program execution begins and ends there.
  2. //
  3.  
  4. #include <iostream>
  5. #include<string.h>
  6.  
  7. using namespace std;
  8.  
  9. class Point
  10. {
  11. private:
  12.     int x;
  13.     int y;
  14.     string name;
  15.  
  16. public:
  17.     Point()
  18.     {
  19.         x = 0;
  20.         y = 0;
  21.         name = "";
  22.     }
  23.  
  24.     void setX(int pointX)
  25.     {
  26.         x = pointX;
  27.     }
  28.  
  29.     int getX()
  30.     {
  31.         return x;
  32.     }
  33.  
  34.     void setY(int pointY)
  35.     {
  36.         y = pointY;
  37.     }
  38.  
  39.     int getY()
  40.     {
  41.         return y;
  42.     }
  43.  
  44.     void setName(string pointName)
  45.     {
  46.         name = pointName;
  47.     }
  48.  
  49.     string getName()
  50.     {
  51.         return name;
  52.     }
  53. };
  54.  
  55. class Circle
  56. {
  57.     Point p;
  58.     int r;
  59.     int pointX, pointY;
  60.     string pointName;
  61. public:
  62.     Circle()
  63.     {
  64.         cout << "Enter radius: ";
  65.         cin >> r;
  66.         cout << endl;
  67.         cout << "Enter name: ";
  68.         cin >> pointName;
  69.         p.setName(pointName);
  70.         cout << endl;
  71.         cout << "Enter x: ";
  72.         cin >> pointX;
  73.         p.setX(pointX);
  74.         cout << endl;
  75.         cout << "Enter y: ";
  76.         cin >> pointY;
  77.         p.setY(pointY);
  78.         cout << endl;
  79.     }
  80.    
  81.     void setR(int radius)
  82.     {
  83.         r = radius;
  84.     }
  85.  
  86.     int getR()
  87.     {
  88.         return r;
  89.     }
  90.  
  91.     void getPointParamets()
  92.     {
  93.         cout << "Radius: " << getR() << endl;
  94.         cout << "X: " << p.getX() << endl;
  95.         cout << "Y: " << p.getY() << endl;
  96.         cout << "Name: " << p.getName() << endl;
  97.     }
  98. };
  99.  
  100.  
  101. int main()
  102. {
  103.     Circle* arr[5];
  104.     for (int i = 0; i < 5; i++)
  105.     {
  106.         arr[i] = new Circle();
  107.     }
  108.     for (int i = 0; i < 5; i++)
  109.     {
  110.         if (arr[i]->getR() > 10)
  111.         {
  112.             arr[i]->getPointParamets();
  113.         }
  114.        
  115.     }
  116. }
  117.  
  118. // Run program: Ctrl + F5 or Debug > Start Without Debugging menu
  119. // Debug program: F5 or Debug > Start Debugging menu
  120.  
  121. // Tips for Getting Started:
  122. //   1. Use the Solution Explorer window to add/manage files
  123. //   2. Use the Team Explorer window to connect to source control
  124. //   3. Use the Output window to see build output and other messages
  125. //   4. Use the Error List window to view errors
  126. //   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
  127. //   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
  128.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement