SCherkasov / MyPlayground

0 stars 0 forks source link

Make area and perimeter as calculable properties, with getters #8

Closed igavrysh closed 6 years ago

igavrysh commented 6 years ago

https://github.com/SCherkasov/MyPlayground/blob/fe756032dfaee9036bac01f1014a2dc8c1c4e554/MyPlayground.playground/Contents.swift#L7-L8

I expect something like

class Shape {
  var area: Float { get }
  var perimeter: Float { get }
}
SCherkasov commented 6 years ago

smthng like this?

class Squere: Rectangle {

private var side: Float

init(side: Float) {

    self.side = side
    super.init(height: side, width: side)
}

var areaa: Float {
    get {
        return pow(self.side, 2)
    }
}

var perimeter: Float {
    get {
        return 4 * self.side
    }
}

}

igavrysh commented 6 years ago

yes and no,

SCherkasov commented 6 years ago

I think fixed)

igavrysh commented 6 years ago

Close issue as soon as you feel it can be closed