-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfirstChallenge.swift
68 lines (27 loc) · 1.59 KB
/
firstChallenge.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//: Playground - noun: a place where people can play
import UIKit
//-----------------TODO (1) --------------------
/** (1) TODO write constant number is initialized with value 10 and the test expression number > 0 evaluates to true. Hence,the
statement print("Number is positive.") inside the body of if statement is executed.
**/
//-----------------TODO (2 & 3) --------------------
// (2) TODO Implement Method which calculate averageScore and return the result-> result = firstScore + secondScore + thirdScore / 3
// NOTE : Declare result variable as Underscore, Becuse result variable that declared but didn't actually use.
// (3) TODO Call Method averageScore + print result
//-----------------TODO (4) --------------------
/** WE have While LOOP the test expression of the while loop is always true. var currentLevel:Int = 1, finalLevel:Int = 2
(Write IF statment, When the currentLevel is greater than finalLevel, break statement inside the if block is executed)
The program then breaks out of (terminates) the while loop and executes the statements after the loop, i.e. print("outside of while loop")
**/
var currentLevel:Int = 1, finalLevel:Int = 2
var isLifeAvailable = true
while (isLifeAvailable) {
//(4) TODO Write IF statment, When the currentLevel is greater than finalLevel, break statement inside the if block is executed
}
//play game and go to next level
currentLevel += 1
print("next level")
}
print("outside of while loop")
//-----------------TODO (5) --------------------
// (5) TODO Implement Switch Statment swich print num =4: