Skip to content
Permalink
Browse files
Add files via upload
P2 logic
  • Loading branch information
thomasv5 committed Nov 27, 2020
1 parent c3aa698 commit 3f236f1ecc59f71c8248efc9520547f603fc74f1
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
@@ -0,0 +1,74 @@
import UIKit

//create an dictionary containing exercises and their calories
var exercises = [11:"Jumping Jacks", 12: "Jogging", 10: "Cycling", 5: "Squats", 9: "Skipping"]
var key = [11,12,10,5,9]





// Generate a workout that equals the target calorie
var user = 3000
var a = user/2
let b = a / 2
let c = b
let d = 0

//ARRAY OF ALL EXERCISES
var aList = [String]()


//EXERCISES AND REPS
var cycling1 = 0
var squats1 = 0
var skipping1 = 0
var jumpingJacks1 = 0
var jogging1 = 0





//CREATING A NEW WORKOUT PLAN
//DAY 1 -> CREATING A LIST OF ALL EXERCISES IN PLAN A
while (a >= 0) {

//generating a random key
var randKey = Int.random(in: 0..<5)
randKey = key[randKey]

//adding the random exercise onto new list
aList.append(exercises[randKey]!)
a = a - randKey
print(a)
}



for counter in 0...aList.count - 1{

let exercise = aList[counter]
switch exercise{
case "Cycling":
cycling1 += 1
case "Squats":
squats1 += 1
case "Skipping":
skipping1 += 1
case "Jumping Jacks":
jumpingJacks1 += 1
case "Jogging":
jogging1 += 1
default:
print("no exercise present")
}
}
print("Cycling FOR \(cycling1) MINS ")
print("Squats FOR \(squats1) MINS ")
print("Skipping FOR \(skipping1) MINS ")
print("Jumping Jacks FOR \(jumpingJacks1) MINS ")
print("Jogging FOR \(jogging1) MINS ")

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version='5.0' target-platform='ios'>
<timeline fileName='timeline.xctimeline'/>
</playground>

0 comments on commit 3f236f1

Please sign in to comment.