-
Notifications
You must be signed in to change notification settings - Fork 240
/
InputUser.kt
58 lines (54 loc) · 1.62 KB
/
InputUser.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import java.lang.Exception
import java.util.*
import kotlin.collections.ArrayList
fun main() {
var user: User? = null
val list = ArrayList<User>()
val inputStream = Scanner(System.`in`)
do {
print(
"""
Menu
1. Update The User
2. Print User Data
3. Quit
Select =
""".trimIndent()
)
val selected = inputStream.nextInt()
if (selected < 1 || selected > 3) {
println("Just select number 1 until 3")
} else {
if (selected == 1) {
print("Name :")
inputStream.nextLine()
val name = inputStream.nextLine()
print("Occupation : ")
val occupation = inputStream.nextLine()
print("Age : ")
val age = inputStream.next()
user = User(name, occupation, age)
list.add(user)
} else if (selected == 2) {
println("Print all the data")
println("The data : ")
for (i in list) {
println(
"""
Name : ${i.name}
Occupation : ${i.occupation}
Age : ${i.age}
""".trimIndent()
)
}
} else {
break
}
}
} while (true)
}
data class User(
var name: String,
var occupation: String,
var age: String
)