-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlugBoard.java
More file actions
32 lines (27 loc) · 1.1 KB
/
PlugBoard.java
File metadata and controls
32 lines (27 loc) · 1.1 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
// Copyright Joan Montas & Andrew Bernal
// All rights reserved.
//
// License under GNU General Public License v3.0
import java.util.HashMap;
public class PlugBoard {
private final HashMap<Character, Character> plugboardMap = new HashMap<>();
private static final String alphabet = "abcdefghijklmnopqrstuvwxyz";
/**Default Constructor to initialize the plugboard without any substitution
*/
public PlugBoard() {
char originalChar;
for (int i = 0; i < alphabet.length(); i++) {
originalChar = (char) ('a' + i);
plugboardMap.put(originalChar, originalChar);
}
}
// TODO(JoanMontas) Andrew please make a constructor that would accept a specific
// rotor configuration. - Joan
/**Given a Char "input-wire", return the corresponding output-wire/letter.
* @param letterWire input wire/letter.
* @return output wire/letter.
*/
public char plugIn(char letterWire) {
return plugboardMap.get(letterWire);
}
}