//: Playground - noun: a place where people can play

import UIKit

class Employee {
    var name : String = ""
    var empYear : Int
    
    init(name : String, empYear: Int) {
        self.name = name
        self.empYear = empYear
    }
    
    var score : Int {
        return Employee.Info.year - self.empYear
    }
    
    func displayInfo(){
        print("\(self.name) : \(self.score) ->  salary : \(self.salary) Tomans.")
    }
    
    var salary : Int {
        return Employee.baseSalary + (self.score * 80_000)
    }
    
    class var baseSalary : Int {
        return 1_000_000 + (Info.year - 1000) * 1400
    }
    
    class func newyear(){
        Info.year += 1
    }
    
    
    struct Info {
        static var year : Int = 1395
    }
}

var emp1 = Employee(name: "Ali", empYear: 1371)
var emp2 = Employee(name: "Hamid", empYear: 1380)

print("---------------------------")
print("in year \(Employee.Info.year) , baseSalary = \(Employee.baseSalary) Tomans")
emp1.displayInfo()
emp2.displayInfo()
print("---------------------------")

Employee.newyear()
print("in year \(Employee.Info.year) , baseSalary = \(Employee.baseSalary) Tomans")
emp1.displayInfo()
emp2.displayInfo()

print("---------------------------")
Employee.newyear()
print("in year \(Employee.Info.year) , baseSalary = \(Employee.baseSalary) Tomans")
emp1.displayInfo()
emp2.displayInfo()


