diff --git a/MyPlayground.playground/Pages/main.xcplaygroundpage/Contents.swift b/MyPlayground.playground/Pages/main.xcplaygroundpage/Contents.swift index 1ff7c6d..4d5a0b0 100644 --- a/MyPlayground.playground/Pages/main.xcplaygroundpage/Contents.swift +++ b/MyPlayground.playground/Pages/main.xcplaygroundpage/Contents.swift @@ -23,7 +23,7 @@ let b = 32 ### **(1)** Print "true" if a modulo b is equal to zero. */ - + print(a % b == 0) @@ -33,7 +33,7 @@ let b = 32 /*: Question 2 ### **(2)** Print 'true' if y divided by x is greater than three, otherwise print 'false'. */ - + print(Double(y) / x > 3) @@ -43,7 +43,7 @@ let b = 32 /*: Question 3 ### **(3)** Print 'true' if y is greater than x and a divided by b is greater than 9. If there's any need to convert to either an `Int` or a `Double` to satisfy the requirements of a binary operator (you can choose whichever one you want to convert to to satisfy the requirements). */ - + print(Double(y) > x && a / b > 9) @@ -54,7 +54,14 @@ let b = 32 /*: Question 4 ### **(4)** Write a function named `isGreater` that takes two `Int` arguments and returns a `String`. This function should look to see if `a` is greater than `b`. If it is, it returns back the `String` 'yep', else it returns back the `String` 'nope`. */ - +func isGreater(arg1:Int, arg2:Int) -> String{ + if arg1 > arg2 { + return "yep" + } else { + return "nope" + } +} +isGreater(arg1: a, arg2: b) @@ -70,11 +77,26 @@ let b = 32 isForce(with:"Mary") // false ``` */ - - - - - +func isForce(arg:String) -> Bool{ + switch arg { + case "Luke": + return true + case "Leia": + return true + case "Anakin": + return true + case "Obi Wan": + return true + case "Yoda": + return true + case "Vader": + return true + default: + return false + } +} + +isForce(arg: "Lala") @@ -86,8 +108,22 @@ let b = 32 isInRange(5) // prints "big" ``` */ - - +func isInRange(arg:Int){ + switch arg { + case 0...3: + print("small") + case 4...6: + print("medium") + case 7...10: + print("big") + default: + print("not sure") + } +} +isInRange(arg:0) +isInRange(arg: 10) +isInRange(arg: 5) +isInRange(arg: -1) diff --git a/MyPlayground.playground/Pages/main.xcplaygroundpage/timeline.xctimeline b/MyPlayground.playground/Pages/main.xcplaygroundpage/timeline.xctimeline index 6eb3657..e64dedf 100644 --- a/MyPlayground.playground/Pages/main.xcplaygroundpage/timeline.xctimeline +++ b/MyPlayground.playground/Pages/main.xcplaygroundpage/timeline.xctimeline @@ -3,48 +3,48 @@ version = "3.0">