-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathGoldToEuroConverter.cpp
More file actions
55 lines (44 loc) · 1.03 KB
/
Copy pathGoldToEuroConverter.cpp
File metadata and controls
55 lines (44 loc) · 1.03 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
#include "GoldToEuroConverter.hpp"
//Constructor
GoldToEuroConverter::GoldToEuroConverter():
_decConv(nullptr)
{}
//Constructior for chaining
GoldToEuroConverter::GoldToEuroConverter(std::shared_ptr<UnitConverter> converter):
_decConv(converter)
{}
/*
converts Celsius to Fahrenheit
[Euro] = [Gold] * 1067.4
Gold value as of 28.10.15
*/
double GoldToEuroConverter::convert(double input)
{
//check whether the converter is decorated
if(_decConv != nullptr)
{
//first conversion
input = _decConv->convert(input);
}
//do the remaining, second conversion
double result = input*1067.4;
return result;
}
std::string GoldToEuroConverter::toString() const
{
std::string output = "Gold to Euro Converter";
//checks whether the converter is decorated
if(_decConv != nullptr)
{
output += " with decorator: " + _decConv->toString();
}
return output;
}
void GoldToEuroConverter::print() const
{
std::cout << toString();
}
std::shared_ptr<UnitConverter> GoldToEuroConverter::clone()
{
return std::make_shared<GoldToEuroConverter>();
}