-
-
Save Alexey-RNR/732cc9381dbb865f879735101d95bee4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Класс Card | |
class Card { | |
val numbers: MutableMap<Int, MutableSet<Int>> = mutableMapOf( | |
1 to mutableSetOf(), | |
2 to mutableSetOf(), | |
3 to mutableSetOf() | |
) | |
} | |
// Класс Person | |
class Person(val name: String) { | |
val card: Card = createCard() | |
private fun createCard(): Card { | |
val newCard = Card() | |
for (row in 1..3) { | |
while (newCard.numbers[row]!!.size < 5) { | |
val randomNumber = Random.nextInt(1, 100) | |
if (!newCard.numbers.values.flatten().contains(randomNumber)) { | |
newCard.numbers[row]!!.add(randomNumber) | |
} | |
} | |
} | |
return newCard | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment