forked from coders-school/object-oriented-programming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexercise2.cpp
More file actions
33 lines (29 loc) · 819 Bytes
/
exercise2.cpp
File metadata and controls
33 lines (29 loc) · 819 Bytes
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
#include <string>
class Ship {
public:
Ship()
: id_(-1)
{}
Ship(int capacity, int maxCrew, int speed, const std::string& name, size_t id)
: capacity_(capacity)
, maxCrew_(maxCrew)
, speed_(speed)
, name_(name)
, id_(id)
{}
Ship(int maxCrew, int speed, size_t id)
: Ship(0, maxCrew, speed, "", id)
{}
void setName(const std::string& name) { name_ = name; }
size_t getCapacity() const { return capacity_; }
size_t getMaxCrew() const { return maxCrew_; }
size_t getSpeed() const { return speed_; }
std::string getName() const { return name_; }
size_t getId() const { return id_; }
private:
size_t capacity_;
size_t maxCrew_;
size_t speed_;
std::string name_;
const size_t id_;
};