From 743d9cff0eb9729f2854785a15f50f084c52af55 Mon Sep 17 00:00:00 2001 From: Isaac Greene Date: Wed, 13 Apr 2022 22:19:11 -0400 Subject: [PATCH] Started turning the ContentView -> PaceResults calculations into functions but as of this commit they don't work so it contains many errors. Also DID make the seconds work properly so 0:00:300 properly wraps to 0:05:00, and likewise, 0:00:86400 properly wraps to 24:00:00. --- FizzBuzz.playground/Contents.swift | 14 +++++++++++++ FizzBuzz.playground/contents.xcplayground | 4 ++++ Splits/ChangeLogData.swift | 12 ++++++++++++ Splits/ContentView.swift | 24 +++++++++++++++-------- 4 files changed, 46 insertions(+), 8 deletions(-) create mode 100644 FizzBuzz.playground/Contents.swift create mode 100644 FizzBuzz.playground/contents.xcplayground diff --git a/FizzBuzz.playground/Contents.swift b/FizzBuzz.playground/Contents.swift new file mode 100644 index 0000000..0e3cb8f --- /dev/null +++ b/FizzBuzz.playground/Contents.swift @@ -0,0 +1,14 @@ +for i in 1...100 { + if i.isMultiple(of: 3) && i.isMultiple(of: 5){ + print("FizzBuzz") + } + else if i.isMultiple(of: 3) { + print("Fizz") + } + else if i.isMultiple(of: 5) { + print("Buzz") + } + else{ + print(i) + } +} diff --git a/FizzBuzz.playground/contents.xcplayground b/FizzBuzz.playground/contents.xcplayground new file mode 100644 index 0000000..cf026f2 --- /dev/null +++ b/FizzBuzz.playground/contents.xcplayground @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Splits/ChangeLogData.swift b/Splits/ChangeLogData.swift index d51bcae..fa3bb55 100644 --- a/Splits/ChangeLogData.swift +++ b/Splits/ChangeLogData.swift @@ -10,6 +10,18 @@ import SwiftUI struct April2022: View { var body: some View { ScrollView { + //2022-04-13 + HStack { + VStack (alignment: .leading) { + Text("2022-04-13") + .font(.title2) + Text("Version Prerelease Build LVSXT10j\n") + .font(.footnote) + Text("\u{2022} Started work on optimizing code. Made no other changes and left the code with errors.") + } + Spacer() + } + .padding(30) //2022-04-11 HStack { diff --git a/Splits/ContentView.swift b/Splits/ContentView.swift index a023cc4..9ba4e79 100644 --- a/Splits/ContentView.swift +++ b/Splits/ContentView.swift @@ -71,17 +71,25 @@ struct PaceResults: View { //var pacePerUnit = 0.0 //var notSelectedSystem = "" - let convertedSeconds = (Double(timeSeconds) ?? 0) * (1+(2/3)) - let timeSecondsInt = Int(timeSeconds) ?? 0 - let timeSecondsUnderSixty = (timeSecondsInt % 60) + func secondsConversion(timeSeconds: String) -> (timeSecondsInt: Int, timeSecondsUnderSixty: Int) { + let convertedSeconds = (Double(timeSeconds) ?? 0) * (1+(2/3)) + let timeSecondsInt = Int(timeSeconds) ?? 0 + let timeSecondsUnderSixty = (timeSecondsInt % 60) + return (timeSecondsInt, timeSecondsUnderSixty) + } - let timeSecondsToMinutes = (timeSecondsInt - timeSecondsUnderSixty) / 60 + func minutesConversion(secondsConversion) { + let timeSecondsToMinutes = (timeSecondsInt - timeSecondsUnderSixty) / 60 - let timeMinutesDouble = Double(timeMinutes) ?? 0.0 + let timeMinutesDouble = Double(timeMinutes) ?? 0.0 + + let timeMinutesInt = (Int(timeMinutes) ?? 0) + (timeSecondsToMinutes) + let timeMinutesUnderSixty = timeMinutesInt % 60 + let timeMinutesToHours = (timeMinutesInt - timeMinutesUnderSixty) / 60 + + return (timeMinutesUnderSixty, timeMinutesDouble, timeMinutesToHours) + } - let timeMinutesInt = (Int(timeMinutes) ?? 0) + (timeSecondsToMinutes) - let timeMinutesUnderSixty = timeMinutesInt % 60 - let timeMinutesToHours = (timeMinutesInt - timeMinutesUnderSixty) / 60 let leadingZeros = String(format: "%02d:%02d", timeMinutesUnderSixty, timeSecondsUnderSixty)