-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFirstViewController.swift
52 lines (39 loc) · 1.39 KB
/
FirstViewController.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//
// FirstViewController.swift
// Mindful Log
//
// Created by Julia Schell on 4/24/18.
// Copyright © 2018 Julia Schell. All rights reserved.
//
import UIKit
class FirstViewController: UIViewController {
@IBOutlet var newExerciseDescription: UILabel!
@IBOutlet weak var revealButton: UIButton!
//store wellness exercises -- consider hashtable or set?
var exerciseList = ["Body awareness", "Controlled breathing", "Stretching", "Exercise"]
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
newExerciseDescription.text = ""
}
//when reveal button is tapped
@IBAction func revealDailyExercise(_ sender: Any) {
loadNewExercise()
}
func loadNewExercise(){
//random number to choose exercise
if exerciseList.isEmpty{
newExerciseDescription.text = "You have completed this set of exercises! Nice job!"
}
else{
let numExercises = UInt32(exerciseList.count)
let random = Int(arc4random_uniform(numExercises))
newExerciseDescription.text = exerciseList[random]
exerciseList.remove(at: random)
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}