From a2e71a67c9caeed3ad2f0040bd1b335071ee1027 Mon Sep 17 00:00:00 2001 From: 328p <328p@BTK.MAIN> Date: Fri, 18 Sep 2026 11:31:47 +0300 Subject: [PATCH] Lesson3 --- works/Lab(Kotlin)/lab-03/lesson3/.gitignore | 32 +++++++++ works/Lab(Kotlin)/lab-03/lesson3/src/Main.kt | 75 ++++++++++++++++++++ 2 files changed, 107 insertions(+) create mode 100644 works/Lab(Kotlin)/lab-03/lesson3/.gitignore create mode 100644 works/Lab(Kotlin)/lab-03/lesson3/src/Main.kt diff --git a/works/Lab(Kotlin)/lab-03/lesson3/.gitignore b/works/Lab(Kotlin)/lab-03/lesson3/.gitignore new file mode 100644 index 0000000..3ddbf4c --- /dev/null +++ b/works/Lab(Kotlin)/lab-03/lesson3/.gitignore @@ -0,0 +1,32 @@ +### IntelliJ IDEA ### +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ + +### Kotlin ### +.kotlin + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/works/Lab(Kotlin)/lab-03/lesson3/src/Main.kt b/works/Lab(Kotlin)/lab-03/lesson3/src/Main.kt new file mode 100644 index 0000000..9e6504f --- /dev/null +++ b/works/Lab(Kotlin)/lab-03/lesson3/src/Main.kt @@ -0,0 +1,75 @@ +//TIP To Run code, press or +// click the icon in the gutter. +fun main() { + println("=== ПРОВЕРКА СОСТОЯНИЯ ПОКЕМОНА ===") + print("Введите текущее HP: ") + val currentHpInput = readln().toInt() + print("Введите количество энергии: ") + val energyAttachedInput = readln().toInt() + + if (currentHpInput <= 0) { + println("Покемон отправлен в нокаут и не может продолжать бой.") + } else { + println("Покемон в строю и готов к бою.") + } + + val attackStatus: String = if (energyAttachedInput >= 3) { + "Доступна атака 'Giga Impact'" + } else { + "Атака 'Giga Impact' недоступна: не хватает карт энергии." + } + println("Статус атаки: $attackStatus") + println("=== РОЗЫГРЫШ КАРТЫ ТРЕНЕРА ===") + print("Введите название карты Тренера: ") + val trainerCardInput = readln() + + when (trainerCardInput) { + "Potion" -> println("Эффект: Лечение +30 HP.") + "Professor's Research" -> println("Эффект: Добор 7 карт из колоды.") + "Switch" -> println("Эффект: Замена активного Покемона.") + else -> println("Эффект: Неизвестная карта Тренера.") + } + println() + + println("=== РАСЧЕТ СТИХИЙНОГО МНОЖИТЕЛЯ ===") + print("Введите стихию Покемона (Fire, Water, Grass, Electric): ") + val elementInput = readln() + + val weaknessMultiplier: Double = when (elementInput) { + "Water" -> { + println("[Слабость к Электричеству]") + 2.0 + } + + "Fire" -> { + println("[Слабость к Воде]") + 1.5 + } + + "Grass" -> { + println("[Слабость к Огню]") + 1.2 + } + + else -> { + println("[Базовый коэффициент стихии]") + 1.0 + } + } + println() + print("Введите текущий % HP (0-100): ") + val hpPercent = readln().toInt() + println() + + val healthState: String = when { + hpPercent == 0 -> "Нокаут" + hpPercent in 1..20 -> "Критическое состояние" + hpPercent in 21..70 -> "Поврежден" + else -> "Отличное состояние" + } + println("========================================") + println("ИТОГОВЫЙ СТАТУС БОЯ:") + println("Множитель урона: x$weaknessMultiplier") + println("Категория здоровья: $healthState") + println("========================================") + }