Last active
June 14, 2020 12:42
-
-
Save TarasShu/706ca0e094eff4f8e5e5d0ff25977b12 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Rectangle { | |
var width: Double = 10 | |
var area: Double = 100 | |
var height: Double { | |
get { | |
return area / width | |
} | |
set (height) { | |
self.area = height * width | |
} | |
} | |
} | |
var newRectangle = Rectangle() | |
newRectangle.area // 10 | |
newRectangle.width = 1 | |
newRectangle.area = 3 | |
///////////////////////////////////////////////////// | |
struct Rectangle1 { | |
var width1: Double | |
var area1: Double | |
init (width1: Double, area1: Double ){ | |
self.width1 = width1 | |
self.area1 = area1 | |
} | |
var height1: Double { | |
get { | |
return area1 / width1 | |
} | |
set (height1) { | |
self.area1 = height1 * width1 | |
} | |
} | |
} | |
var newRectangle1 = Rectangle1(width1: 1, area1: 3 ) | |
newRectangle1.area1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment