-
Notifications
You must be signed in to change notification settings - Fork 0
/
tas-kagit-makas.swift
62 lines (51 loc) · 1.48 KB
/
tas-kagit-makas.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
60
61
62
func getUserChoice(userInput: String) -> String {
if userInput == "taş" || userInput == "kağıt" || userInput == "makas" {
return userInput;
} else {
return "Sadece taş, kağıt ve makas seçebilirsiniz."
}
}
func getComputerChoice() -> String {
let random = Int.random(in: 0...2)
switch random {
case 0:
return "taş"
case 1:
return "kağıt"
case 2:
return "makas"
default:
return "Bilinmeze doğru?"
}
}
func determineWinner(_ userChoice: String, _ compChoice: String) -> String {
var decision: String = "Fifti Fifti, Dostluk Kazandı!"
switch userChoice {
case "taş":
if compChoice == "kağıt" {
decision = "Sistem kazandı"
} else if compChoice == "makas"{
decision = "Sen kazandın!"
}
case "kağıt":
if compChoice == "taş" {
decision = "Hadi ama beni yendin!"
} else if compChoice == "makas"{
decision = "MR. Robot Kazandı."
}
case "makas":
if compChoice == "taş" {
decision = "01010101 Kazandı!"
} else if compChoice == "kağıt" {
decision = "Hehehe tabiki humoon!"
}
default:
print("Piston aşaaa...404...Kaptan bir sorunumuz var!")
}
return decision
}
let userChoice = getUserChoice(userInput: "kağıt") // Buraya seçminizi girin.
let compChoice = getComputerChoice()
print("Sen: \(userChoice)")
print("010110110: \(compChoice)")
print(determineWinner(userChoice, compChoice))