-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcargo.cpp
More file actions
60 lines (49 loc) · 1011 Bytes
/
Copy pathcargo.cpp
File metadata and controls
60 lines (49 loc) · 1011 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
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
/*
* kjs170430_Project5/cargo.cpp
* Copyright 2017, Kristopher Sewell, All rights reserved.
*
* Course: CE1337 Section: 501 Project: 5
*/
#include "cargo.hpp"
Cargo::Cargo()
{
_src_weight = 0;
_type = "";
}
Cargo::Cargo(weight w, std::string t)
{
_src_weight = abs(w);
setType(t);
}
void Cargo::setEarthWgt(const std::shared_ptr<Planet> p)
{
this->_earth_weight = p->earthwgt(this->_src_weight);
}
void Cargo::setDstWgt(const std::shared_ptr<Planet> p)
{
this->_dst_weight = p->planetwgt(this->_earth_weight);
}
void Cargo::setSrcWgt(weight w)
{
this->_src_weight = abs(w);
}
void Cargo::setType(std::string t)
{
this->_type = std::strlen(t.c_str()) > static_cast<size_t>(32) ? t.substr(0, 29) + "..." : t;
}
weight Cargo::getEarthWgt() const
{
return this->_earth_weight;
}
weight Cargo::getDstWgt() const
{
return this->_dst_weight;
}
weight Cargo::getSrcWgt() const
{
return this->_src_weight;
}
std::string Cargo::printType() const
{
return this->_type;
}