-
Notifications
You must be signed in to change notification settings - Fork 0
/
point.cpp
62 lines (45 loc) · 1022 Bytes
/
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
#include "point.h"
using namespace Animator;
Point::Point(void)
:x(0.0),
y(0.0)
{
}
Point::Point(const float& new_x, const float& new_y)
:x(new_x),
y(new_y)
{
}
void Point::toStream(std::ostream & output_stream) const
{
output_stream << x << std::endl;
output_stream << y << std::endl;
}
void Point::fromStream(std::istream & input_stream)
{
input_stream >> x;
input_stream >> y;
}
namespace Animator
{
std::ostream & operator<<(std::ostream & output_stream, const Animator::Point & point)
{
point.toStream(output_stream);
return output_stream;
}
std::istream & operator>>(std::istream & input_stream, Animator::Point & point)
{
point.fromStream(input_stream);
return input_stream;
}
}
bool PointSmallerXCompare::operator()(const Point & first, const Point & second) const
{
bool hasSmallerX = (first.x < second.x);
return hasSmallerX;
}
bool PointLargerXCompare::operator()(const Point & first, const Point & second) const
{
bool hasLargerX = (first.x > second.x);
return hasLargerX;
}