cli용 맥앱 랜덤빙고게임

쏘스야·2023년 4월 5일
0

ios 개발자의 첫걸음

목록 보기
44/61
//
//  main.swift
//  RandomBingo
//
//  Created by 조소야 on 2023/04/05.
//

import Foundation

var computerChoice = Int.random(in: 1...10)
var myChoice: Int = 0

print("RandomBing Start!!")


while true {
    print("숫자를 입력해주세요.")
    var userInput = readLine()

    if let input = userInput {
        if let number = Int(input) {
            myChoice = number
        }
    }

    if computerChoice > myChoice {
        print("Up")
    } else if computerChoice < myChoice {
        print("Down")
    } else {
        print("Bingo!!")
        break   // 반복문을 종료
    }
}
profile
개발자

0개의 댓글