• API
• FAQ
• Tools
• Archive
SHARE
TWEET # Untitled a guest Jun 21st, 2018 43 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. // Course.cpp : Defines the entry point for the console application.
2. //
3.
4. #include "stdafx.h"
5. #include <iostream>
6. #include <iomanip>
7. #include <math.h>
8. #include <string>
9. using namespace std;
10. const double pi = 3.14159265359;
11. class Point
12. {
13. private:
14.     double x;
15.     double y;
16. public:
17.     Point();
18.     Point(double cx, double cy);
19.     Point(double cx);
20.     Point(double cy);
21.     Point(Point &cord);
22.     Point& operator=(Point &cord);
23.
24.     double get_X();
25.     double get_Y();
26.
27.     bool operator <=(Point cord);
28.
29.     void set_X(double cx);
30.     void set_Y(double cy);
31.     void set_cord(double cx, double cy);
32.
33.     void inputP();
34.     void outputP();
35.     friend ostream& operator<<(ostream& output, Point cord);
36. };
37. Point::Point() {
38.     this->x = 0;
39.     this->y = 0;
40. }
41. Point::Point(double cx, double cy) {
42.     this->x = cx;
43.     this->y = cy;
44. }
45. Point::Point(double cx) {
46.     x = cx;
47.     y = 0;
48. }
49. Point::Point(double cy) {
50.     x = 0;
51.     y = cy;
52. }
53. Point::Point(Point &cord) {
54.     x = cord.x;
55.     y = cord.y;
56. }
57. Point& Point::operator=(Point &cord) {
58.     x = cord.x;
59.     y = cord.y;
60.     return *this;
61. }
62. double Point::get_X() {
63.     return x;
64. }
65. double Point::get_Y() {
66.     return y;
67. }
68.
69. bool Point::operator <=(Point cord) {
70.     if (this->y != cord.y) {
71.         cout << "error !!!";
72.         return false;
73.     }
74.     else
75.         if (this->x < cord.y) return true;
76.         else return false;
77. }
78. void Point::set_X(double cx) {
79.     this->x = cx;
80. }
81. void Point::set_Y(double cy) {
82.     this->y = cy;
83. }
84. void Point::set_cord(double cx, double cy) {
85.     this->x = cx;
86.     this->y = cy;
87. }
88. void Point::inputP() {
89.     cout << "X= ";
90.     cin >> x;
91.     cout << "Y= ";
92.     cin >> y;
93. }
94.
95. void Point::outputP() {
96.     cout << "[" << this->x << ", " << this->y << "]";
97. }
98. ostream& operator<<(ostream& output, Point cord) {
99.     cout << cord.x << " " << cord.y;
100.     return output;
101. }
102. class Ellipse : public Point
103. {
104. private:
105.     double small;
106.     double big;
107.
108. public:
109.     Ellipse();
110.     Ellipse(double csmall, double cbig, double cx, double cy);
111.     Ellipse(double csmall, double cbig, Point cord);
112.     Ellipse(Ellipse &el);
113.     Ellipse& operator=(Ellipse &el);
114.
115.     double get_small();
116.     double get_big();
117.
118.     Point get_center();
119.
120.     bool operator ==(Ellipse el);
121.
122.     void set_Ellipse(double csmall, double cbig, double cx, double cy);
123.
124.     double areaEl();
125.     double perEl();
126.     bool isInside();
127.
128.     void inputEl();
129.     void outputEl();
130. };
131.
132.
133. Ellipse::Ellipse() : Point() {
134.     double small = 0;
135.     double big = 0;
136.
137. }
138. Ellipse::Ellipse(double csmall, double cbig, double cx, double cy)
139.     : Point(cx, cy) {
140.     csmall = small;
141.     cbig = big;
142. }
143. Ellipse::Ellipse(double csmall, double cbig, Point cord) : Point(cord) {
144.     small = csmall;
145.     big = cbig;
146. }
147. Ellipse::Ellipse(Ellipse &el) : Point(el) {
148.     small = el.small;
149.     big = el.big;
150. }
151. Ellipse& Ellipse::operator=(Ellipse &el) {
152.     if (this != &el)
153.     {
154.         Point::operator=(el);
155.         small = el.small;
156.         big = el.big;
157.         return*this;
158.     }
159. }
160. Point Ellipse::get_center() {
161.     Point center;
162.     center.set_X(this->get_X());
163.     center.set_Y(this->get_Y());
164.     return center;
165. }
166.
167. void Ellipse::outputEl() {
168.     cout << small << "\t" << big << "Center:";
169.     outputP();
170. }
171.
172. double Ellipse::get_big() {
173.     return big;
174. }
175. double Ellipse::get_small() {
176.     return small;
177. }
178.
179. bool Ellipse::operator ==(Ellipse el) {
180.     return big == el.big;
181. }
182. void Ellipse::set_Ellipse(double csmall, double cbig, double cx, double cy) {
183.     small = csmall;
184.     big = cbig;
185.     this->set_X(cx);
186.     this->set_Y(cy);
187. }
188.
189. void Ellipse::inputEl() {
190.     cout << "small - "; cin >> small;
191.     cout << "big - "; cin >> big;
192.     this->inputP();
193. }
194. double Ellipse::areaEl() {
195.     return small * big * pi;
196. }
197. double Ellipse::perEl() {
198.
199.     return pi*(1.5 * (small + big) - sqrt(small * big));
200. }
201.
202. bool Ellipse::isInside() {
203.     //return (dx * dx) / (width * width) + (dy * dy) / (height * height) <= 1
204. }
205.
206. int main()
207. {
208.     return 0;
209. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top