From 7e4dc51da8886745a6b745a6c50f5b59a15bda46 Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Sun, 17 Jan 2021 16:30:18 -0500 Subject: [PATCH] [O] Move default values to alarm constructor --- ProjectClock/Models.swift | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/ProjectClock/Models.swift b/ProjectClock/Models.swift index 0035ad2..e3a73e8 100644 --- a/ProjectClock/Models.swift +++ b/ProjectClock/Models.swift @@ -38,29 +38,38 @@ let wvms = [ class Alarm: Codable { - var enabled: Bool = true + var enabled: Bool var hour: Int // Hour (24) var minute: Int var text: String var wakeMethod: WVM - init(hour: Int, minute: Int, text: String, wakeMethod: WVM) + /// What days does it repeat (Sun, Mon, Tue, Wed, Thu, Fri, Sat) + var repeats: [Bool] + + /// Does it automatically disable after activating once + var oneTime: Bool + + /// When is the last time that the alarm went off + var lastActivate: Date + + /// Constructor + init(enabled: Bool = true, + hour: Int, minute: Int, text: String, wakeMethod: WVM, + repeats: [Bool] = [false, true, true, true, true, true, false], + oneTime: Bool = false, lastActivate: Date = Date() + ) { + self.enabled = enabled self.hour = hour self.minute = minute self.text = text self.wakeMethod = wakeMethod + self.repeats = repeats + self.oneTime = oneTime + self.lastActivate = lastActivate } - /// What days does it repeat (Sun, Mon, Tue, Wed, Thu, Fri, Sat) - var repeats: [Bool] = [false, true, true, true, true, true, false] - - /// Does it automatically disable after activating once - var oneTime = false - - /// When is the last time that the alarm went off - var lastActivate: Date = Date() - /// When should the alarm activate next since lastActivate? var nextActivate: Date? {