-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFederation.hpp
More file actions
136 lines (118 loc) · 3.24 KB
/
Copy pathFederation.hpp
File metadata and controls
136 lines (118 loc) · 3.24 KB
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
126
127
128
129
130
131
132
133
134
135
136
/*
** EPITECH PROJECT, 2024
** ppool07am
** File description:
** Federation
*/
#pragma once
#include <iostream>
#include <string>
#include <utility>
#include "Destination.hpp"
#include "WarpSystem.hpp"
namespace Federation {
class Ship {
public:
explicit Ship(int length, int width, std::string name);
void setupCore(WarpSystem::Core *core);
void checkCore();
bool move(int warp, Destination d) {
if (!canMove(warp, d))
return false;
_location = d;
return true;
}
bool move(int warp) { return move(warp, _location); }
bool move(Destination d) {
if (!canMove(d))
return false;
_location = d;
return true;
}
bool move() { return move(_home); }
private:
int _length;
int _width;
std::string _name;
short _maxWarp = 0;
WarpSystem::Core *_core = nullptr;
Destination _home = VULCAN;
Destination _location = _home;
bool canMove(Destination d) const {
return d != _location && _core->checkReactor()->isStable();
}
bool canMove(int warp, Destination d) const {
return warp <= _maxWarp && canMove(d);
}
void displayInfo(const std::string &str) const {
std::cout << _name << ": " << str << "\n";
}
};
} // namespace Federation
namespace Federation::Starfleet {
class Captain {
public:
Captain(std::string name) : _name(std::move(name)) {}
std::string getName() const { return _name; }
int getAge() const { return _age; }
void setAge(int age) { _age = age; }
private:
std::string _name;
int _age = 0;
};
class Ship {
public:
explicit Ship(
int length, int width, std::string name, short maxWarp,
int torpedo = 0);
void setupCore(WarpSystem::Core *core);
void checkCore();
void promote(Captain *captain);
int getShield() const { return _shield; }
void setShield(int shield) { _shield = shield; }
int getTorpedo() const { return _photonTorpedo; }
void setTorpedo(int torpedo) { _photonTorpedo = torpedo; }
bool move(int warp, Destination d) {
if (!canMove(warp, d))
return false;
_location = d;
return true;
}
bool move(int warp) { return move(warp, _location); }
bool move(Destination d) {
if (!canMove(d))
return false;
_location = d;
return true;
}
bool move() { return move(_home); }
private:
int _length;
int _width;
std::string _name;
short _maxWarp;
WarpSystem::Core *_core = nullptr;
Captain *_captain = nullptr;
int _shield = 100;
int _photonTorpedo;
Destination _home = EARTH;
Destination _location = _home;
bool canMove(Destination d) const {
return d != _location && _core->checkReactor()->isStable();
}
bool canMove(int warp, Destination d) const {
return warp <= _maxWarp && canMove(d);
}
void displayInfo(const std::string &str) const {
std::cout << "USS " << _name << ": " << str << "\n";
}
};
class Ensign {
public:
explicit Ensign(std::string name) : _name(std::move(name)) {
std::cout << "Ensign " << _name << ", awaiting orders.\n";
}
private:
std ::string _name;
};
} // namespace Federation::Starfleet