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 trial

iOS Object-Oriented Swift Inheritance Overriding Methods

Daniel Szulc
Daniel Szulc
3,220 Points

expected declaration error

Check my screenshot -> screenshot link

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()
    override func discountedPrice(percentage: Double = 10.0) -> Double {
        return super.discountedPrice(percentage)
}

var tshirt = Clothing(title: "Vintage", price: 49.99)
tshirt.title
tshirt.price
tshirt.discountedPrice(50)
tshirt.size

let quadcopter = Product(title: "Quadcopter", price: 499.99)

2 Answers

Jhoan Arango
Jhoan Arango
14,575 Points

Hello:

There is nothing wrong with your code, the only thing that is missing is a closing curly brace in your Clothing Class.

} <---

Good luck