Research portable Memory game | Исследовать портируемую игру Память
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

7 mesi fa
7 mesi fa
7 mesi fa
7 mesi fa
7 mesi fa
12345678910111213141516171819202122232425262728293031323334353637383940
  1. package my.program
  2. // L4: Function.
  3. fun memory_generateConstPlayfield(
  4. n: Int
  5. ): Map<Int, Int> {
  6. var idGroups: MutableMap<Int, Int> = mutableMapOf()
  7. var id = 0
  8. for (gid in 0..<n) {
  9. idGroups[id] = gid
  10. id += 1
  11. idGroups[id] = gid
  12. id += 1
  13. }
  14. return idGroups
  15. }
  16. // L20: Test.
  17. fun test_memory_generateConstPlayfield(): String {
  18. val idGroups = memory_generateConstPlayfield(2)
  19. if (
  20. idGroups.count() == 4 &&
  21. idGroups[0] == 0 &&
  22. idGroups[1] == 0 &&
  23. idGroups[2] == 1 &&
  24. idGroups[3] == 1
  25. ) {
  26. return "OK: memory_generateConstPlayfield"
  27. }
  28. return "ERR: memory_generateConstPlayfield"
  29. }
  30. // L36: Run.
  31. fun main(args: Array<String>) {
  32. println(test_memory_generateConstPlayfield())
  33. }