-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPoint.cpp
63 lines (51 loc) · 1.21 KB
/
Point.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "Point.h"
#include <iostream>
Point::Point():x(0.), y(0.), z(0.){}
Point::Point(double x = 0., double y = 0., double z = 0.):x(x), y(y), z(z){}
Point::Point(const Point& obj) : Point(obj) {}
Point::~Point() {}
void Point::setX(double x) {
this->x = x;
}
void Point::setY(double y){
this->y = y;
}
void Point::setZ(double z) {
this->z = z;
}
double Point::getX()const {
return x;
}
double Point::getY()const {
return y;
}
double Point::getZ()const {
return z;
}
bool Point::operator==(const Point&b)const {
bool equal = (this->x == b.getX() && this->y == b.getY() && this->z == b.getZ());
return equal;
}
void Point::print()const {
std::cout << "The point is (" << x << "," << y << "," << z << ").\n";
}
std::ostream& operator<<(std::ostream & out,
const Point & rhs) {
out << rhs.getX() << ", " << rhs.getY() << ", " << rhs.getZ();
return out;
}
std::istream& operator>>(std::istream & in,
Point & rhs) {
setlocale(LC_ALL, "Bulgarian");
double x, y, z;
std::cout << "Please enter õ: ";
in >> x;
std::cout << "Please enter y: ";
in >> y;
std::cout << "Please enter z: ";
in >> z;
rhs.setX(x);
rhs.setY(y);
rhs.setZ(z);
return in;
}