Advertisement
tamerSabek

14032019_7

Mar 14th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.47 KB | None | 0 0
  1. import Foundation
  2.  
  3. class Ruler{
  4.  
  5.     var inche:Double{
  6.         get{
  7.             return cm*2.54
  8.         }
  9.         set{
  10.             cm = newValue / 2.54
  11.         }
  12.     }
  13.     var cm:Double = 0.0
  14.  
  15.     init(cm:Double) {
  16.         self.cm = cm    
  17.     }
  18.    
  19.     init(inche:Double) {
  20.      self.inche = inche    
  21.     }
  22.  
  23. }
  24.  
  25. let  num = Ruler(cm : 10)
  26. print (num.cm)
  27. print (num.inche)
  28.  
  29. print()
  30.  
  31. let num1 = Ruler(inche : 25.4)
  32. print (num1.cm)
  33. print (num1.inche)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement