-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtile.hxx
125 lines (97 loc) · 2.21 KB
/
tile.hxx
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#pragma once
#include <stdexcept>
#include "tile.hh"
namespace Djikstra
{
inline constexpr Tile::Tile(int x, int y, bool is_start, bool is_arrival) :
is_arrival_(is_arrival),
is_start_(is_start),
x_(x),
y_(y)
{
if (x_ < 0)
throw std::out_of_range("X is lower than 0");
if (y_ < 0)
throw std::out_of_range("Y is lower than 0");
}
inline void Tile::start_set() noexcept
{
is_start_ = true;
}
inline void Tile::arrival_set() noexcept
{
is_arrival_ = true;
}
inline Tile* Tile::father_get() const noexcept
{
return father_;
}
inline bool Tile::is_arrival() const noexcept
{
return is_arrival_;
}
inline void Tile::type_set(char tile) noexcept
{
switch (tile)
{
case Type::GRASS:
type_ = Type::GRASS;
break;
case Type::WALL:
type_ = Type::WALL;
break;
case Type::ROAD:
type_ = Type::ROAD;
break;
case Type::WATER:
type_ = Type::WATER;
default:
type_ = Type::WALL;
}
}
inline bool Tile::is_start() const noexcept
{
return is_start_;
}
inline void Tile::cood_set(int x, int y) noexcept
{
x_ = x;
y_ = y;
}
inline constexpr Tile::operator int () const
{
return x_;
}
inline void Tile::weight_set(int weight) noexcept
{
weight_ = weight;
}
inline void Tile::listed_set() noexcept
{
is_listed_ = true;
}
inline void Tile::father_set(Tile * const father) noexcept
{
father_ = father;
}
inline bool Tile::is_listed() const noexcept
{
return is_listed_;
}
inline int Tile::weight_get() const noexcept
{
return weight_;
}
inline int Tile::x_get() const noexcept
{
return x_;
}
inline int Tile::y_get() const noexcept
{
return y_;
}
inline Tile::Type Tile::type_get() const noexcept
{
return type_;
}
}