Mode:
Duration:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
object ConditionalThemeCounter {
var count = 0
var isDark = false
def updateUI(): Unit = {
isDark = count % 2 == 0
println(s"Counter: $count")
println(s"Theme: ${if(isDark) "Dark" else "Light"}")
}
def increment(): Unit = { count += 1; updateUI() }
def decrement(): Unit = { count -= 1; updateUI() }
def reset(): Unit = { count = 0; updateUI() }
def main(args: Array[String]): Unit = {
updateUI()
increment()
increment()
increment()
decrement()
reset()
}
}
ConditionalThemeCounter.main(Array())Coding works best on desktop or with an external keyboard.