Revert "Merge branch 'main' of github.com:hykilpikonna/ProjectClock into main"

This reverts commit ecd15bb30a, reversing
changes made to acfcdbed24.
This commit is contained in:
Aaron
2021-01-21 14:29:56 -05:00
parent ecd15bb30a
commit e41c0ea067
4 changed files with 43 additions and 40 deletions
@@ -12,41 +12,41 @@ class AlarmActivationViewController: UIViewController
{
var timer: Timer?
var currentAlarm: Alarm?
//Outlets
@IBOutlet weak var puzzleView: UIView!
@IBOutlet weak var puzzleQuestionLabel: UILabel!
@IBOutlet weak var puzzleAnswerInput: UITextField!
var puzzleAnswers: [Int] = []
init?(coder: NSCoder, currentAlarm: Alarm)
{
self.currentAlarm = currentAlarm
//print(currentAlarm.wakeMethod)
super.init(coder: coder)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func viewDidLoad()
{
super.viewDidLoad()
//Hide all inactive wakemethods
puzzleView.isHidden = true
timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(AlarmActivationViewController.playSound), userInfo: nil, repeats: true)
setAlarmType()
print(MathExpression.random())
}
@objc func playSound()
{
AudioServicesPlayAlertSound(SystemSoundID(1005))
AudioServicesPlayAlertSound(kSystemSoundID_Vibrate)
}
func setAlarmType()
{
if let alarm = currentAlarm
@@ -66,13 +66,10 @@ class AlarmActivationViewController: UIViewController
}
}
}
@IBAction func checkPuzzleSolution(_ sender: Any) {
if puzzleAnswers.contains(Int(puzzleAnswerInput.text!)!) {
print("alarm solved")
}
@IBAction func debugForceStop(_ sender: Any)
{
timer?.invalidate()
}
}
+2 -11
View File
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="s8U-C8-W2S">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17156" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="s8U-C8-W2S">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17125"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
@@ -669,22 +669,13 @@
</subviews>
<color key="backgroundColor" systemColor="systemGray6Color"/>
</view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="oLm-Yh-rM4">
<rect key="frame" x="114.5" y="778" width="185" height="30"/>
<state key="normal" title="[DEBUG] Force Stop Alarm"/>
<connections>
<action selector="debugForceStop:" destination="hDW-11-g9U" eventType="touchUpInside" id="nko-gr-9Fu"/>
</connections>
</button>
</subviews>
<viewLayoutGuide key="safeArea" id="hS6-fS-yWp"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="oLm-Yh-rM4" firstAttribute="bottom" secondItem="hS6-fS-yWp" secondAttribute="bottom" id="5EN-4c-jdo"/>
<constraint firstItem="vmg-Oj-8tB" firstAttribute="top" secondItem="hS6-fS-yWp" secondAttribute="top" constant="20" id="5lz-9m-i9F"/>
<constraint firstItem="vmg-Oj-8tB" firstAttribute="leading" secondItem="hS6-fS-yWp" secondAttribute="leading" constant="20" id="7fm-Y8-FaE"/>
<constraint firstItem="42Q-0v-ZS3" firstAttribute="top" secondItem="vmg-Oj-8tB" secondAttribute="bottom" constant="-5" id="GNM-uI-sQt"/>
<constraint firstItem="oLm-Yh-rM4" firstAttribute="centerX" secondItem="BZn-UX-vps" secondAttribute="centerX" id="HxH-v7-dVA"/>
<constraint firstItem="hS6-fS-yWp" firstAttribute="trailing" secondItem="42Q-0v-ZS3" secondAttribute="trailing" constant="20" id="L1F-Bv-r5M"/>
<constraint firstItem="42Q-0v-ZS3" firstAttribute="leading" secondItem="hS6-fS-yWp" secondAttribute="leading" constant="20" id="Nbf-jB-Uq5"/>
<constraint firstItem="mjE-Hr-RIc" firstAttribute="centerY" secondItem="BZn-UX-vps" secondAttribute="centerY" id="SFw-9a-XAc"/>
+29 -14
View File
@@ -2,7 +2,7 @@
// MathExpressions.swift
// ProjectClock
//
// MathElement
// Class that will generate a simple math expression
import Foundation
@@ -118,23 +118,38 @@ let c = MathExpression.random()
}
}
class quadraticProb{
//generates the roots
let root1 = Int.random(in: 1...10)//ax^2
let root2 = Int.random(in: 1...10)//bx
func getProblem() -> String{
//a value is 1
let b = root1 + root2 // b value
let c = root1 * root2 // c value
return "x^2 + \(b)x + \(c)"
}
class QuadraticProb{
let a = Int.random(in: 1...10)//ax^2
let b = Int.random(in: 1...10)//bx
let c = Int.random(in: 1...10)//c
var roots = [Int]()
func getProblem() -> String{
return "\(a)x^2 + \(b)x + \(c)"
}
//finds the roots of the quadratic **NOTE**: the return type is [Int], not a String
func getAnswer() -> [Int]{
let roots = [root1, root2]
let d = Int(pow(Double(b), 2) - 4 * Double(a) * Double(c)) // discriminant
// if d>0 , equation has two distinct real roots exist.
if d > 0 {
let x1 = Int((-Double(b) + sqrt(Double(d)))/(2*Double(a)))
let x2 = Int((-Double(b) - sqrt(Double(d)))/(2*Double(a)))
roots = [x1, x2]
}
//if d=0, equation has two repeated real roots.
else if d == 0 {
let x = Int(-Double(b)/(2*Double(a)))
roots = [x]
}
// if d<0 equation has two complex roots, but idk how to calculate that by hand, so we'll return nothing
else if d < 0 {
roots = []
}
return roots
}
}