From ed6d06015dbaaa4005626ac205eac02ea01b54d4 Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Sun, 19 Jul 2015 08:20:55 -0700 Subject: [PATCH] Rotor.notch The turnover point for the adjacent rotor --- Enigma/Components.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Enigma/Components.swift b/Enigma/Components.swift index 73db1ae..0a1edb4 100644 --- a/Enigma/Components.swift +++ b/Enigma/Components.swift @@ -128,6 +128,15 @@ class Rotor: FixedRotor { } } + /** An offset at which the adjacent rotor should be advanced by one position. */ + var notch: Int? { + willSet { + if let newInt = newValue { + self.notch = newInt % series.count + } + } + } + func advance(count: Int = 1) { position = (position + count) % Rotor.alphabet.count }