Created
May 21, 2016 21:29
-
-
Save yvettecook/8b160575172024fe74500cccbc852eb6 to your computer and use it in GitHub Desktop.
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
class ViewController: UIViewController { | |
var score = 0 | |
@IBOutlet weak var numberButton: UIButton! | |
@IBAction func numberButtonTapped(sender: UIButton) { | |
let calculator = Calculator() | |
if calculator.check(score + 1) == "Number" { | |
incrementScore() | |
} | |
} | |
@IBAction func fizzButtonTapped(sender: UIButton) { | |
let calculator = Calculator() | |
if calculator.check(score + 1) == "Fizz" { | |
incrementScore() | |
} | |
} | |
@IBAction func buzzButtonTapped(sender: UIButton) { | |
let calculator = Calculator() | |
if calculator.check(score + 1) == "Buzz" { | |
incrementScore() | |
} | |
} | |
@IBAction func fizzBuzzButtonTapped(sender: UIButton) { | |
let calculator = Calculator() | |
if calculator.check(score + 1) == "FizzBuzz" { | |
incrementScore() | |
} | |
} | |
func incrementScore() { | |
score += 1 | |
numberButton.setTitle("\(score)", forState: .Normal) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment