-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathobject.h
76 lines (57 loc) · 1.54 KB
/
object.h
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
64
65
66
67
68
69
70
71
72
73
74
75
76
//
// Created by Aykut Ismailov on 29.4.2020 г..
//
#ifndef HDMAP_OBJECT_H
#define HDMAP_OBJECT_H
#include <ostream>
#include "object_type.h"
class object
{
int x;
int y;
object_type type;
public:
object(int x, int y, enum object_type object_type) : x(x), y(y), type(object_type)
{
}
object() : x(0), y(0), type(object_type::Invalid)
{
}
int getX() const;
int getY() const;
enum object_type getObjectType() const;
friend double distance(object start, object end);
friend std::ostream& operator<<(std::ostream& out, object object);
friend inline bool operator<(const object& lhs, const object& rhs)
{
return (lhs.getX() == rhs.getX()) ? lhs.getY() < rhs.getY() : lhs.getX() < rhs.getX();
}
friend inline bool operator>(const object& lhs, const object& rhs)
{
return rhs < lhs;
}
friend inline bool operator<=(const object& lhs, const object& rhs)
{
return !(lhs > rhs);
}
friend inline bool operator>=(const object& lhs, const object& rhs)
{
return !(lhs < rhs);
}
friend inline bool operator==(const object& lhs, const object& rhs)
{
return (lhs.getX() == rhs.getX() && lhs.getY() == rhs.getY());
}
friend inline bool operator!=(const object& lhs, const object& rhs)
{
return !(rhs == lhs);
}
inline object& operator=(const object& rhs)
{
this->x = rhs.x;
this->y = rhs.y;
this->type = rhs.type;
return *this;
}
};
#endif //HDMAP_OBJECT_H