Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialChristiaan Hendriksen
5,982 PointsCode from Last Stage won't run in Playground
I've downloaded the code from the last exercise (included at the end of this question) but when I try to run it in the playground I get the following error:
Communication with the playground service was interrupted unexpectedly
Here's the code I'm using:
import UIKit
class Product { let title: String var price: Double = 0.0
init(title: String, price: Double) {
self.title = title
self.price = price
}
func discountedPrice(percentage: Double) -> Double {
return price - (price * percentage / 100)
}
}
enum Size { case Small, Medium, Large init() { self = .Small } }
class Clothing: Product { var size = Size() let designer: String
init (title: String, price: Double, designer: String) {
self.designer = designer
super.init(title: title, price: price)
}
convenience init (title: String) {
self.init(title:title,price:99,designer:"Calvin Klein")
}
override func discountedPrice(_ percentage: Double = 10.0) -> Double {
return super.discountedPrice(percentage)
}
}
var tshirt = Clothing(title: "Vintage") tshirt.title tshirt.price tshirt.designer tshirt.discountedPrice(50) tshirt.size
let quadcopter = Product(title: "Quadcopter", price: 499.99)