Skip to content

Instantly share code, notes, and snippets.

View ciryon's full-sized avatar

Christian Hedin ciryon

View GitHub Profile
@ciryon
ciryon / VendRefactored.swift
Created January 3, 2016 09:27 — forked from eofster/VendRefactored.swift
Vending machine vend() function refactored
func vend(itemNamed name: String) throws {
let item = try validatedItemNamed(name)
reduceDepositedCoinsBy(item.price)
removeFromInventory(item, name: name)
dispense(name)
}
private func validatedItemNamed(name: String) throws -> Item {
let item = try itemNamed(name)
try validate(item)
-(void)checkAnswer:(int)answer {
if(rightAnswer==answer)
{
//AudioServicesPlaySystemSound(_tweetSound);
score++;
}
else {
//AudioServicesPlaySystemSound(_barkSound);
}
[self updateScore];