Created
November 20, 2015 19:36
-
-
Save MMercieca/aad57599442afdef4770 to your computer and use it in GitHub Desktop.
Speed enum
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Speed.swift | |
// 30-20-10 | |
// | |
// Created by Matthew Mercieca on 8/14/15. | |
// Copyright (c) 2015 Mutually Human. All rights reserved. | |
// | |
import UIKit | |
enum Speed { | |
case Jog | |
case Run | |
case Sprint | |
case Break | |
case Warmup | |
case Finished | |
func description() -> String { | |
switch self { | |
case .Jog: | |
return "Jog" | |
case .Run: | |
return "Run" | |
case .Sprint: | |
return "Sprint" | |
case .Break: | |
return "Jog" | |
case .Warmup: | |
return "Warmup" | |
case .Finished: | |
return "Finished" | |
} | |
} | |
func color() -> UIColor { | |
switch self { | |
case .Jog: | |
return UIColor.blueColor() | |
case .Run: | |
return UIColor.orangeColor() | |
case .Sprint: | |
return UIColor.redColor() | |
case .Break: | |
return UIColor.blueColor() | |
case .Warmup: | |
return UIColor.blueColor() | |
case .Finished: | |
return UIColor.blueColor() | |
} | |
} | |
func soundUrl() -> NSURL { | |
switch self { | |
case .Jog, | |
.Warmup, | |
.Break: | |
return NSBundle.mainBundle().URLForResource("a", withExtension: "mp3")! | |
case .Run: | |
return NSBundle.mainBundle().URLForResource("c", withExtension: "mp3")! | |
case .Sprint: | |
return NSBundle.mainBundle().URLForResource("a2", withExtension: "mp3")! | |
case .Finished: | |
return NSBundle.mainBundle().URLForResource("finished", withExtension: "mp3")! | |
} | |
} | |
func runFor() -> Double { | |
switch self { | |
case .Jog: | |
return 30.0 | |
case .Run: | |
return 20.0 | |
case .Sprint: | |
return 10.0 | |
case .Break: | |
return 120.0 | |
case .Warmup: | |
return 300.0 | |
case .Finished: | |
return 0.0 | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment