/// <summary> /// Initialize a MarkMark machine. /// </summary> public MarkMark(Reflector reflector, PlugBoard frontPlugBoard, params Module[] modules) : base(reflector.OperatingAlphabet) { if (reflector == null) { throw new ArgumentNullException(nameof(reflector)); } Reflector = reflector; if (modules == null) { modules = new Module[0]; } Modules = modules; foreach (Module module in modules) { if (module.Rotor != null && !Reflector.Equals(module.Rotor)) { throw new ArgumentNullException("A rotor does not use the same Alphabet that the others."); } } if (frontPlugBoard == null) { frontPlugBoard = new PlugBoard(); } else { FrontPlugBoard = frontPlugBoard; } }
/// <summary> /// Initialize a Enigma machine. /// </summary> public Enigma(Reflector reflector, PlugBoard plugBoard, params RotorEnigma[] rotors) : base(reflector.OperatingAlphabet) { if (reflector == null) { throw new ArgumentNullException(nameof(reflector)); } Reflector = reflector; if (rotors == null) { rotors = new RotorEnigma[0]; } Rotors = rotors; foreach (RotorEnigma rotor in rotors) { if (!Reflector.Equals(rotor)) { throw new ArgumentNullException("A rotor does not use the same Alphabet that the others."); } } Reset(); if (plugBoard == null) { PlugBoard = new PlugBoard(); } else { PlugBoard = plugBoard; } }