-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.kt
More file actions
38 lines (28 loc) · 739 Bytes
/
Main.kt
File metadata and controls
38 lines (28 loc) · 739 Bytes
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
package search
import java.nio.file.Files
import java.nio.file.Paths
import java.util.*
val scanner = Scanner(System.`in`)
fun main(args: Array<String>) {
val list = if (args.size > 1 && args[0] == "--data") {
readFile(args[1])
} else {
readList()
}
val search = Search(list)
search.run()
println("Bye!")
}
fun readFile(path: String): List<String> {
return Files.readAllLines(Paths.get(path))
}
fun readList(): List<String> {
println("Enter the number of people:")
val peopleNumber = scanner.nextLine().toInt()
val list = mutableListOf<String>()
println("Enter all people:")
for (i in 1..peopleNumber) {
list.add(scanner.nextLine())
}
return list
}