generated from Coding-Cuddles/bootstrap-cpp-kata
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mars_rover.h
44 lines (35 loc) · 1.11 KB
/
mars_rover.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
#pragma once
#include <memory>
#include <iostream>
#include <string>
/**
* A class template to express an equality comparison interface
*/
template <typename T> class EqualityComparable {
friend bool operator==(const T& lhs, const T& rhs) { return lhs.equal_to(rhs); }
friend bool operator!=(const T& lhs, const T& rhs) { return !lhs.equal_to(rhs); }
};
struct Location : private EqualityComparable<Location> {
Location() = delete;
Location(int x, int y, char orientation) : x(x), y(y), orientation(orientation) {}
bool equal_to(const Location& other) const
{
return x == other.x && y == other.y && orientation == other.orientation;
}
int x, y;
char orientation;
};
// Let Google Test know how to print this
inline std::ostream&
operator<<(std::ostream& os, const Location& location)
{
os << '(' << location.x << ',' << location.y << ',' << location.orientation << ')';
return os;
}
class MarsRover {
public:
MarsRover() = delete;
MarsRover(Location location) : location(std::move(location)) {}
void move(const std::string& commands) {}
Location location;
};