Добавил новые работы

This commit is contained in:
gcn
2026-11-25 11:25:37 +03:00
parent b06b1acf69
commit 2b1f86a4a5
219 changed files with 6971 additions and 45 deletions
+10
View File
@@ -0,0 +1,10 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Ignored default folder with query files
/queries/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
+1
View File
@@ -0,0 +1 @@
Main.kt
@@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="ReplaceUntilWithRangeUntil" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
</profile>
</component>
+10
View File
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Kotlin2JvmCompilerArguments">
<option name="jvmTarget" value="1.8" />
</component>
<component name="KotlinCommonCompilerArguments">
<option name="apiVersion" value="2.4" />
<option name="languageVersion" value="2.4" />
</component>
</project>
@@ -0,0 +1,17 @@
<component name="libraryTable">
<library name="KotlinJavaRuntime" type="repository">
<properties maven-id="org.jetbrains.kotlin:kotlin-stdlib:2.4.10" />
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib/2.4.10/kotlin-stdlib-2.4.10.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/annotations/13.0/annotations-13.0.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib/2.4.10/kotlin-stdlib-2.4.10-javadoc.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/annotations/13.0/annotations-13.0-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib/2.4.10/kotlin-stdlib-2.4.10-sources.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/annotations/13.0/annotations-13.0-sources.jar!/" />
</SOURCES>
</library>
</component>
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="graalvm-jdk-21" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
+8
View File
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/lab-05.iml" filepath="$PROJECT_DIR$/lab-05.iml" />
</modules>
</component>
</project>
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
</component>
</project>
+67
View File
@@ -0,0 +1,67 @@
# Лабораторная работа №5
---
## Ключевой код
```kotlin
fun main() {
println("=== ФОРМИРОВАНИЕ КОЛОДЫ ===")
val deck: MutableList<String> = mutableListOf()
var counter = 1
repeat(3) {
print("Введите карту №$counter: ")
val card = readln()
deck.add(card)
counter++
}
println("Колода собрана (${deck.size} карт): ${deck.joinToString(", ")}")
print("Какую карту сбросить? ")
val discardedCard = readln()
val wasDiscarded = 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"}
val trainerNames = trainerCards.map { it.key }
println("Карт Тренеров в руке: ${trainerCards.size} (${trainerNames.joinToString(", ")})")
val allCards = hand.map {it.key}
val energyCount = hand.count {it.value == "Energy"}
println("Карт энергии в руке: $energyCount")
println("Содержимое руки: ${allCards.joinToString(", ")}")
println("\n=== УЧЕТ РЕСУРСОВ ===")
print("Сколько энергии прикрепить? ")
val energyToAttach = readln().toInt()
val resources = mutableMapOf("Trainer" to 2, "Energy" to 1)
resources["Energy"] = resources.getValue("Energy") + energyToAttach
println("Ресурсы на столе: ")
for ((type, count) in resources) {
println("$type: $count шт.")
}
println("\n========================================")
println("ИТОГ: Колода: ${deck.size} карт | Рука: ${hand.size} карт | Энергия на столе: ${resources["Energy"]}")
println("========================================")
}
```
+15
View File
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/testResources" type="java-test-resource" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
</component>
</module>
+59
View File
@@ -0,0 +1,59 @@
fun main() {
println("=== ФОРМИРОВАНИЕ КОЛОДЫ ===")
val deck: MutableList<String> = mutableListOf()
var counter = 1
repeat(3) {
print("Введите карту №$counter: ")
val card = readln()
deck.add(card)
counter++
}
println("Колода собрана (${deck.size} карт): ${deck.joinToString(", ")}")
print("Какую карту сбросить? ")
val discardedCard = readln()
val wasDiscarded = 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"}
val trainerNames = trainerCards.map { it.key }
println("Карт Тренеров в руке: ${trainerCards.size} (${trainerNames.joinToString(", ")})")
val allCards = hand.map {it.key}
val energyCount = hand.count {it.value == "Energy"}
println("Карт энергии в руке: $energyCount")
println("Содержимое руки: ${allCards.joinToString(", ")}")
println("\n=== УЧЕТ РЕСУРСОВ ===")
print("Сколько энергии прикрепить? ")
val energyToAttach = readln().toInt()
val resources = mutableMapOf("Trainer" to 2, "Energy" to 1)
resources["Energy"] = resources.getValue("Energy") + energyToAttach
println("Ресурсы на столе: ")
for ((type, count) in resources) {
println("$type: $count шт.")
}
println("\n========================================")
println("ИТОГ: Колода: ${deck.size} карт | Рука: ${hand.size} карт | Энергия на столе: ${resources["Energy"]}")
println("========================================")
}