Advertisement
Guest User

Untitled

a guest
Feb 20th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. #include <graphics.h>
  2. #include<iostream>
  3. using namespace std;
  4.  
  5. class Circle{
  6. private:
  7. int x, y, radius, color;
  8.  
  9. public:
  10. Circle(int _x, int _y, int r, int c )
  11. {
  12. x = _x; y=_y; radius = r; color = c;
  13. }
  14.  
  15. int getColor()
  16. {
  17. return color;
  18. }
  19.  
  20. int getRadius()
  21. {
  22. return radius;
  23. }
  24.  
  25. void setColor(int c)
  26. {
  27. color = c;
  28. }
  29.  
  30. void setRadius(int r)
  31. {
  32. radius = r;
  33. }
  34.  
  35.  
  36. ~Circle()
  37. {
  38. }
  39.  
  40. void draw()
  41. {
  42. setcolor(color);
  43. circle(x,y, radius);
  44. }
  45.  
  46. void undraw()
  47. {
  48. setcolor(BLACK);
  49. circle(x,y, radius);
  50. }
  51.  
  52. void move(int dx, int dy)
  53. {
  54. x += dx;
  55. y += dy;
  56. }
  57.  
  58. };
  59.  
  60.  
  61.  
  62.  
  63.  
  64. int main( )
  65. {
  66. initwindow(800, 300, "First Sample");
  67.  
  68. Circle c1(150, 80, 80, YELLOW);
  69. Circle c2(200, 100, 50, COLOR(0,0,255));
  70.  
  71. Circle c(50, 80, 50, YELLOW);
  72.  
  73. for (int i=0; i<150; i++)
  74. {
  75. c.draw();
  76. delay(100);
  77. c.undraw();
  78. c.move(10,0);
  79.  
  80. if (kbhit()) break;
  81. }
  82.  
  83.  
  84.  
  85.  
  86. //circle(100, 50, 40);
  87.  
  88. while (!kbhit( ))
  89. {
  90. delay(200);
  91. }
  92. return 0;
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement