Session 12 Swift IOS Code

 IOS Mobile Application Development        

Session 12 Swift IOS Code

//class
class Temperature
{
  var temp: Double
  init()
  {
    temp = 32.0
  }
}
 var t = Temperature()
 print("The default temperature of city: \(t.temp)")


 class Employee
 {
var salary: Int 
init(salary: Int)
{
  self.salary = salary
}

func salaryEmp()
{
  print("The salary of Manager is: \(salary)")
}

 }

 var E = Employee(salary : 48000)
 E.salaryEmp()
 
 class Calculate
 {
   let a : Int
   let b: Int
   let c : Int

   init(a: Int, b: Int)
   {
     self.a = a
     self.b = b
     c = a + b
   }
   func total(cc: Int) ->Int
   {
     return c - cc
   }
   func result()
   {
     print("Result: \(total(cc: 5))")
       print("Result: \(total(cc: 6))")
   }
 }

 var C = Calculate(a: 50, b: 60)
 C.result()
print(C.total(cc:20))

No comments:

Post a Comment

Fell free to write your query in comment. Your Comments will be fully encouraged.