Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Foundation
- class Building{
- var floors:Int{
- willSet{
- foundationCount += 1
- }
- didSet{
- moneyspent += 1000
- }
- }
- var height:Int{
- get{
- return floors * 10
- }
- set{
- floors = newValue / 10
- }
- }
- var foundationCount = 0
- var moneyspent = 0
- init (floors:Int){
- self.floors = floors
- }
- }
- let building = Building(floors:3)
- print(building.floors)
- print(building.height)
- building.height = 20
- print(building.floors)
- print(building.height)
Add Comment
Please, Sign In to add comment