minError

PlayGrounds [ 스위치 모으기 ] 본문

PlayGround/코딩배우기 2

PlayGrounds [ 스위치 모으기 ]

동빠기 2020. 2. 27. 17:38

 

 

//1. 보석과 스위치의 갯수 세아리는 변수 생성.

var swithchCounter = 0

var gemCounter = 0


while switchCounter < gemCounter || switchCounter == 0 {

	while !isBlocked {
    
    //2. 첫번째, 발판 보석 수집하고, 수량 세아리기

		if isOnGem {

			collectGem()

			gemCounter += 1
		}

		moveForward()

	}

	//3. 두번째, 수집한 보석의 갯수만큼 스위치 작동

	if isOnClosedSwitch && switchCounter < gemCounter {

		toggleSwitch()

		switchCounter += 1

	}

	turnRight()

}
Comments