generated from admin/template
add file
This commit is contained in:
@@ -1,14 +1,44 @@
|
||||
//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
|
||||
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
|
||||
fun main() {
|
||||
val name = "Kotlin"
|
||||
//TIP Press <shortcut actionId="ShowIntentionActions"/> with your caret at the highlighted text
|
||||
// to see how IntelliJ IDEA suggests fixing it.
|
||||
println("Hello, " + name + "!")
|
||||
|
||||
for (i in 1..5) {
|
||||
//TIP Press <shortcut actionId="Debug"/> to start debugging your code. We have set one <icon src="AllIcons.Debugger.Db_set_breakpoint"/> breakpoint
|
||||
// for you, but you can always add more by pressing <shortcut actionId="ToggleLineBreakpoint"/>.
|
||||
println("i = $i")
|
||||
println("=== ФОРМИРОВАНИЕ КОЛОДЫ ===")
|
||||
val deck: MutableList<String> = mutableListOf()
|
||||
repeat(3) { index ->
|
||||
print("Введите карту №${index + 1}: ")
|
||||
val card = readln()
|
||||
deck.add(card)
|
||||
}
|
||||
println("Колода собрана (${deck.size} карт): ${deck.joinToString(", ")}")
|
||||
print("\nКакую карту сбросить? ")
|
||||
val discardedCard = readln()
|
||||
val wasDiscarded: Boolean = deck.remove(discardedCard)
|
||||
if (wasDiscarded) {
|
||||
println("✔ Карта '$discardedCard' сброшена. Осталось: ${deck.size}")
|
||||
} else {
|
||||
println("✘ Карта '$discardedCard' не найдена в колоде.")
|
||||
}
|
||||
println("\n=== АНАЛИЗ РУКИ ===")
|
||||
val hand = mapOf(
|
||||
"Pikachu" to "Pokemon",
|
||||
"Potion" to "Trainer",
|
||||
"Fire Energy" to "Energy",
|
||||
"Professor's Research" to "Trainer"
|
||||
)
|
||||
val trainerCards = hand.filter { it.value == "Trainer" }
|
||||
println("Карт Тренеров в руке: ${trainerCards.size} (${trainerCards.keys.joinToString(", ")})")
|
||||
val energyCount = hand.count { it.value == "Energy" }
|
||||
println("Карт энергии в руке: $energyCount")
|
||||
val cardNames = hand.map { it.key }
|
||||
println("Содержимое руки: ${cardNames.joinToString(", ")}")
|
||||
println("\n=== УЧЕТ РЕСУРСОВ ===")
|
||||
val resources = mutableMapOf("Trainer" to 2, "Energy" to 1)
|
||||
print("Сколько энергии прикрепить? ")
|
||||
val energyToAttach = readln().toInt()
|
||||
resources["Energy"] = resources.getValue("Energy") + energyToAttach
|
||||
println("Ресурсы на столе:")
|
||||
for ((type, count) in resources) {
|
||||
println("$type: $count шт.")
|
||||
}
|
||||
println()
|
||||
println("========================================")
|
||||
println("ИТОГ: Колода: ${deck.size} карт | Рука: ${hand.size} карт | Энергия на столе: ${resources["Energy"]}")
|
||||
println("========================================")
|
||||
}
|
||||
Reference in New Issue
Block a user