Follow by Email

Search This Blog

Tuesday, 3 June 2014

How to right function in swift language

func whatsYourStatus (age:Int, name:String) ->(String)
{
    var answer=""
   
    if(age < 0)
    {
        answer = "you need to born first!"
    }
    else if(age < 13)
    {
        answer = "you are not ready for programing"
    }
    else if(age >= 13 && age <= 19)
    {
        answer = "you can start programing"
    }
    else if(age > 19 && age <= 25)
    {
        answer = "you are an expert of Objective-C"
    }
    else if(age > 25 && age <= 30)
    {
        answer = "you are not ready for swift"
    }
    else if(age > 30 && age <= 35)
    {
        answer = "you are an expert of swift"
    }
    else if(age > 35)
    {
        answer="you are retired , have time with your family"
    }
    return "\(name) \(answer)"
}

whatsYourStatus(45, "Kareem")

No comments:

Post a Comment