SCherkasov / MyPlayground

0 stars 0 forks source link

Use assert(...) here for checking your code #4

Open igavrysh opened 6 years ago

igavrysh commented 6 years ago

https://github.com/SCherkasov/MyPlayground/blob/dd5196d81e5e6f50dd8a4aab9c00a23b6b5459bd/MyPlayground.playground/Contents.swift#L64-L77

igavrysh commented 6 years ago

I ll give you a hint how to use assert in this case:

let delta = pow(10, -9)

let radius = 12
assert(abs(Circle(radius: radius).area - pow(radius, 2) * pi) < delta)

let height = 34
assert(Square(side: height).area == pow(height,  2))
assert(Square(side: height).perimeter == height * 4)

let width = 5
assert(Rectangle(width:widht, height: height).area == 2 * width * height)
SCherkasov commented 6 years ago

added asserts without Circle().perimeter