-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.kt
37 lines (33 loc) · 819 Bytes
/
Main.kt
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
package src
import search.SearchEngineWithMenu
import search.Stage1
import search.Stage2
const val MSG = "Please input the number of stage, 1 to 5:"
const val WRONG_INPUT = "Wrong input, please enter a number between 1 to 5:"
fun getStage(): Int {
println(MSG)
var input = -1
while (input < 1) {
try {
readln().toInt().apply {
require(this in 1..5)
input = this
}
} catch (e: Exception) {
println(WRONG_INPUT)
}
}
return input
}
fun runStage(stageNumber: Int) {
println("Running Stage$stageNumber.kt")
when(stageNumber) {
1 -> Stage1().run()
2 -> Stage2().run()
3-> SearchEngineWithMenu().run()
}
}
fun main(args: Array<String>) {
val num = getStage()
runStage(num)
}