-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReflector.cpp
More file actions
59 lines (41 loc) · 1.57 KB
/
Reflector.cpp
File metadata and controls
59 lines (41 loc) · 1.57 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
/*
-----------------------------------------------------------------------------------
Laboratoire : 02
Fichier : Reflector.cpp
Auteur(s) : Doran Kayoumi, Jérémie Melly, Pierre-Olivier Sandoz
Date : 07.03.2019
But : Implémentation de la classe Reflector
Remarque(s) : -
Compilateur : MinGW-g++ 6.3.0
-----------------------------------------------------------------------------------
*/
#include "Reflector.h"
#include <algorithm>
using namespace std;
const string Reflector::ENTRY = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const vector<vector<string>> Reflector::DEFAULT_CONFIG = {
{"UKW-A", "EJMZALYXVBWFCRQUONTSPIKHGD"},
{"UKW-B", "YRUHQSLDPXNGOKMIEBFZCWVJAT"},
{"UKW-C", "FVPJIAOYEDRZXWGCTKUQSBNMHL"},
};
string Reflector::getConfig(const string &ID) {
for (vector<string> config : Reflector::DEFAULT_CONFIG) {
if (config.at(0) == ID) return config.at(1);
}
// If this point is reached, the wanted config doesn't exist
// an exception should be thrown if this point is reached
}
Reflector::Reflector(const string &ID) : ID(ID), WIRING(Reflector::getConfig(ID)) {}
char Reflector::getCharReflect(char c) {
return this->WIRING.at(Reflector::ENTRY.find(c));
}
Reflector &Reflector::operator=(const Reflector &REFLECTOR) {
(string &) this->WIRING = REFLECTOR.WIRING;
(string &) this->ID = REFLECTOR.ID;
return *this;
}
ostream &operator<<(ostream &os, const Reflector &reflector) {
os << "reflector : " << reflector.ID << endl
<< "wiring : " << reflector.WIRING << endl;
return os;
}