Михаил Капелько pirms 8 mēnešiem
vecāks
revīzija
9a17647cc2
1 mainītis faili ar 36 papildinājumiem un 1 dzēšanām
  1. +36
    -1
      main.kt

+ 36
- 1
main.kt Parādīt failu

@@ -1,5 +1,40 @@
package my.program


// L4: Function.

fun memory_generateConstPlayfield(
n: Int
): Map<Int, Int> {
var idGroups: MutableMap<Int, Int> = mutableMapOf()
var id = 0
for (gid in 0..<n) {
idGroups[id] = gid
id += 1
idGroups[id] = gid
id += 1
}
return idGroups
}

// L20: Test.

fun test_memory_generateConstPlayfield(): String {
val idGroups = memory_generateConstPlayfield(2)
if (
idGroups.count() == 4 &&
idGroups[0] == 0 &&
idGroups[1] == 0 &&
idGroups[2] == 1 &&
idGroups[3] == 1
) {
return "OK: memory_generateConstPlayfield"
}
return "ERR: memory_generateConstPlayfield"
}

// L36: Run.

fun main(args: Array<String>) {
println("Hello, World from Kotlin")
println(test_memory_generateConstPlayfield())
}

Notiek ielāde…
Atcelt
Saglabāt