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

This commit is contained in:
2026-10-01 10:59:26 +03:00
parent 10492a4133
commit 88a73bfcb5
186 changed files with 4008 additions and 0 deletions
+32
View File
@@ -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
+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 @@
Readme.md
@@ -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" default="true" project-jdk-name="openjdk-26" 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-04.iml" filepath="$PROJECT_DIR$/lab-04.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>
+70
View File
@@ -0,0 +1,70 @@
## task 1
```kotlin
var deckSize = 60
var cardsInHand = 0
println("Введите кол-во карт: ")
var targetDrawInput = readln().toInt()
while (cardsInHand < targetDrawInput && deckSize > 0){
cardsInHand++
deckSize--
}
println("[ДОБОР] Взята карта №$targetDrawInput В руке: $cardsInHand карт, в колоде осталось: $deckSize")
```
## task 2
```kotlin
var energyCost = -1
while(energyCost < 0) {
print("Введите кол-во энергии: ")
energyCost = readln().toInt()
if (energyCost < 0) {
println("[ОШИБКА] Стоимость атаки не может быть отрицательной! Попробуйте снова.")
} else if (energyCost >= 0) {
println("[УСПЕХ] Корректная стоимость атаки принята: ...")
}
}
```
## task 3
```kotlin
var enemyHp = readln().toInt()
var round = 1
while (round <= 10) {
if (round % 2 == 0) {
println("[Эффект Защиты] Раунд пропускается.")
}
else if (enemyHp <= 0){
println("Покемон противника упал без сил! Прерываем бой.")
break
}
else {
enemyHp -= 25
println("Раунд $round: Нанесено 25 урона. У противника осталось $enemyHp HP.")
}
round++
```
## task 4 PART A
```kotlin
var damageCounters = 0
val maxCounters = 5
while (damageCounters < maxCounters){
damageCounters++
println("Наложен жетон урона №$damageCounters")
}
```
## PART B
```kotlin
var statusDuration = 3
while (statusDuration > 0) {
println("Покемон находится под действием эффекта 'Паралич'. Осталось ходов: $statusDuration")
statusDuration--
}
println("Действие эффекта 'Паралич' закончилось!")
```
Создаем счетчик `statusDuration` запускаем цикл пока счетчик больше нуля далее ввыводим `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>
+55
View File
@@ -0,0 +1,55 @@
fun main(){
println("Task 1")
var deckSize = 60
var cardsInHand = 0
println("Введите кол-во карт: ")
var targetDrawInput = readln().toInt()
while (cardsInHand < targetDrawInput && deckSize > 0){
cardsInHand++
deckSize--
}
println("[ДОБОР] Взята карта №$targetDrawInput В руке: $cardsInHand карт, в колоде осталось: $deckSize")
println("Task 2")
var energyCost = -1
while(energyCost < 0) {
print("Введите кол-во энергии: ")
energyCost = readln().toInt()
if (energyCost < 0) {
println("[ОШИБКА] Стоимость атаки не может быть отрицательной! Попробуйте снова.")
} else if (energyCost >= 0) {
println("[УСПЕХ] Корректная стоимость атаки принята: ...")
}
}
println("Task 3")
print("Введите хп вржеского покемона: ")
var enemyHp = readln().toInt()
var round = 1
while (round <= 10) {
if (round % 2 == 0) {
println("[Эффект Защиты] Раунд пропускается.")
}
else if (enemyHp <= 0){
println("Покемон противника упал без сил! Прерываем бой.")
break
}
else {
enemyHp -= 25
println("Раунд $round: Нанесено 25 урона. У противника осталось $enemyHp HP.")
}
round++
}
println("Task 4")
var damageCounters = 0
val maxCounters = 5
while (damageCounters < maxCounters){
damageCounters++
println("Наложен жетон урона №$damageCounters")
}
}