8 |
9 | The signature of the function is:
10 | ```kotlin
11 | fun trimPicture(picture: String): String
12 | ```
13 |
14 |
15 | Here's an example of the `trimPicture` function's work:
16 |
17 |
18 |
--------------------------------------------------------------------------------
/AlmostDone/MultiRowStrings/test/MainClass.kt:
--------------------------------------------------------------------------------
1 | import org.jetbrains.academy.test.system.core.models.classes.TestClass
2 |
3 | internal val mainClass = TestClass(
4 | classPackage = "jetbrains.kotlin.course.almost.done",
5 | customMethods = listOf(trimPictureMethod)
6 | )
7 |
--------------------------------------------------------------------------------
/AlmostDone/MultiRowStrings/test/Methods.kt:
--------------------------------------------------------------------------------
1 | import org.jetbrains.academy.test.system.core.models.TestKotlinType
2 | import org.jetbrains.academy.test.system.core.models.method.TestMethod
3 | import org.jetbrains.academy.test.system.core.models.variable.TestVariable
4 |
5 | internal val trimPictureMethod = TestMethod(
6 | "trimPicture", TestKotlinType("String"), listOf(
7 | TestVariable("picture", "String"),
8 | )
9 | )
10 |
--------------------------------------------------------------------------------
/AlmostDone/NullSafety/src/main/kotlin/jetbrains/kotlin/course/almost/done/PreDefinedSymbols.kt:
--------------------------------------------------------------------------------
1 | @file:Suppress("MayBeConst")
2 |
3 | package jetbrains.kotlin.course.almost.done
4 |
5 | val borderSymbol = '#'
6 | val separator = ' '
7 | val newLineSymbol = System.lineSeparator()
8 |
9 | fun getPictureWidth(picture: String) = picture.lines().maxOfOrNull { it.length } ?: 0
10 |
11 | fun getPictureByName(name: String) = allImages[name]
12 |
13 | fun allPictures() = allImages.keys
14 |
--------------------------------------------------------------------------------
/AlmostDone/NullSafety/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: edu
2 | custom_name: Console Photoshop - chooseFilter Function
3 | files:
4 | - name: test/Tests.kt
5 | visible: false
6 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/PreDefinedSymbols.kt
7 | visible: false
8 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/Main.kt
9 | visible: true
10 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/Images.kt
11 | visible: false
12 | - name: test/PhotoshopTestsUtils.kt
13 | visible: false
14 | - name: test/Methods.kt
15 | visible: false
16 | - name: test/MainClass.kt
17 | visible: false
18 | feedback_link: https://docs.google.com/forms/d/e/1FAIpQLScylICclQIi9_YDjO7iuyRITDLn0Qgzw_aLxKxiishKAbL0qg/viewform?usp=pp_url&entry.2103429047=Introduction/Almost+done/Null+safety
19 |
--------------------------------------------------------------------------------
/AlmostDone/NullSafety/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 553691845
2 |
--------------------------------------------------------------------------------
/AlmostDone/NullSafety/test/MainClass.kt:
--------------------------------------------------------------------------------
1 | import org.jetbrains.academy.test.system.core.models.classes.TestClass
2 |
3 | internal val mainClass = TestClass(
4 | classPackage = "jetbrains.kotlin.course.almost.done",
5 | customMethods = listOf(
6 | trimPictureMethod,
7 | applyBordersFilterMethod,
8 | applySquaredFilterMethod,
9 | applyFilterMethod,
10 | chooseFilterMethod,
11 | safeReadLineMethod,
12 | )
13 | )
14 |
--------------------------------------------------------------------------------
/AlmostDone/NullSafetyPartTwo/src/main/kotlin/jetbrains/kotlin/course/almost/done/PreDefinedSymbols.kt:
--------------------------------------------------------------------------------
1 | @file:Suppress("MayBeConst")
2 |
3 | package jetbrains.kotlin.course.almost.done
4 |
5 | val borderSymbol = '#'
6 | val separator = ' '
7 | val newLineSymbol = System.lineSeparator()
8 |
9 | fun getPictureWidth(picture: String) = picture.lines().maxOfOrNull { it.length } ?: 0
10 |
11 | fun getPictureByName(name: String) = allImages[name]
12 |
13 | fun allPictures() = allImages.keys
14 |
--------------------------------------------------------------------------------
/AlmostDone/NullSafetyPartTwo/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: edu
2 | custom_name: Console Photoshop - getPicture Function
3 | files:
4 | - name: test/Tests.kt
5 | visible: false
6 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/Images.kt
7 | visible: false
8 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/Main.kt
9 | visible: true
10 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/PreDefinedSymbols.kt
11 | visible: false
12 | - name: test/PhotoshopTestsUtils.kt
13 | visible: false
14 | - name: test/Methods.kt
15 | visible: false
16 | - name: test/MainClass.kt
17 | visible: false
18 | feedback_link: https://docs.google.com/forms/d/e/1FAIpQLScylICclQIi9_YDjO7iuyRITDLn0Qgzw_aLxKxiishKAbL0qg/viewform?usp=pp_url&entry.2103429047=Introduction/Almost+done/Null+safety+part+two
19 |
--------------------------------------------------------------------------------
/AlmostDone/NullSafetyPartTwo/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 1368513525
2 |
--------------------------------------------------------------------------------
/AlmostDone/NullSafetyPartTwo/test/MainClass.kt:
--------------------------------------------------------------------------------
1 | import org.jetbrains.academy.test.system.core.models.classes.TestClass
2 |
3 | internal val mainClass = TestClass(
4 | classPackage = "jetbrains.kotlin.course.almost.done",
5 | customMethods = listOf(
6 | trimPictureMethod,
7 | applyBordersFilterMethod,
8 | applySquaredFilterMethod,
9 | applyFilterMethod,
10 | chooseFilterMethod,
11 | choosePictureMethod,
12 | getPictureMethod,
13 | safeReadLineMethod,
14 | ),
15 | )
16 |
--------------------------------------------------------------------------------
/AlmostDone/StringFunctions/src/main/kotlin/jetbrains/kotlin/course/almost/done/PreDefinedSymbols.kt:
--------------------------------------------------------------------------------
1 | @file:Suppress("MayBeConst")
2 |
3 | package jetbrains.kotlin.course.almost.done
4 |
5 | val borderSymbol = '#'
6 | val separator = ' '
7 | val newLineSymbol = System.lineSeparator()
8 |
9 | fun getPictureWidth(picture: String) = picture.lines().maxOfOrNull { it.length } ?: 0
10 |
11 | fun getPictureByName(name: String) = allImages[name]
12 |
13 | fun allPictures() = allImages.keys
14 |
--------------------------------------------------------------------------------
/AlmostDone/StringFunctions/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: edu
2 | custom_name: Console Photoshop - applyBordersFilter Implementation
3 | files:
4 | - name: test/Tests.kt
5 | visible: false
6 | - name: test/PhotoshopTestsUtils.kt
7 | visible: false
8 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/Main.kt
9 | visible: true
10 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/PreDefinedSymbols.kt
11 | visible: false
12 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/Images.kt
13 | visible: false
14 | - name: test/Methods.kt
15 | visible: false
16 | - name: test/MainClass.kt
17 | visible: false
18 | feedback_link: https://docs.google.com/forms/d/e/1FAIpQLScylICclQIi9_YDjO7iuyRITDLn0Qgzw_aLxKxiishKAbL0qg/viewform?usp=pp_url&entry.2103429047=Introduction/Almost+done/String+functions
19 |
--------------------------------------------------------------------------------
/AlmostDone/StringFunctions/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 999114955
2 |
--------------------------------------------------------------------------------
/AlmostDone/StringFunctions/test/MainClass.kt:
--------------------------------------------------------------------------------
1 | import org.jetbrains.academy.test.system.core.models.classes.TestClass
2 |
3 | internal val mainClass = TestClass(
4 | classPackage = "jetbrains.kotlin.course.almost.done",
5 | customMethods = listOf(
6 | applyBordersFilterMethod,
7 | applySquaredFilterMethod,
8 | applyFilterMethod,
9 | trimPictureMethod,
10 | )
11 | )
12 |
--------------------------------------------------------------------------------
/AlmostDone/StringFunctionsPartTwo/src/main/kotlin/jetbrains/kotlin/course/almost/done/PreDefinedSymbols.kt:
--------------------------------------------------------------------------------
1 | @file:Suppress("MayBeConst")
2 |
3 | package jetbrains.kotlin.course.almost.done
4 |
5 | val borderSymbol = '#'
6 | val separator = ' '
7 | val newLineSymbol = System.lineSeparator()
8 |
9 | fun getPictureWidth(picture: String) = picture.lines().maxOfOrNull { it.length } ?: 0
10 |
11 | fun getPictureByName(name: String) = allImages[name]
12 |
13 | fun allPictures() = allImages.keys
14 |
--------------------------------------------------------------------------------
/AlmostDone/StringFunctionsPartTwo/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: edu
2 | custom_name: Console Photoshop - applySquaredFilter Implementation
3 | files:
4 | - name: test/Tests.kt
5 | visible: false
6 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/Main.kt
7 | visible: true
8 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/PreDefinedSymbols.kt
9 | visible: false
10 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/Images.kt
11 | visible: false
12 | - name: test/PhotoshopTestsUtils.kt
13 | visible: false
14 | - name: test/Methods.kt
15 | visible: false
16 | - name: test/MainClass.kt
17 | visible: false
18 | feedback_link: https://docs.google.com/forms/d/e/1FAIpQLScylICclQIi9_YDjO7iuyRITDLn0Qgzw_aLxKxiishKAbL0qg/viewform?usp=pp_url&entry.2103429047=Introduction/Almost+done/String+functions+part+two
19 |
--------------------------------------------------------------------------------
/AlmostDone/StringFunctionsPartTwo/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 1835776409
2 |
--------------------------------------------------------------------------------
/AlmostDone/StringFunctionsPartTwo/test/MainClass.kt:
--------------------------------------------------------------------------------
1 | import org.jetbrains.academy.test.system.core.models.classes.TestClass
2 |
3 | internal val mainClass = TestClass(
4 | classPackage = "jetbrains.kotlin.course.almost.done",
5 | customMethods = listOf(
6 | trimPictureMethod,
7 | applyBordersFilterMethod,
8 | applySquaredFilterMethod,
9 | applyFilterMethod,
10 | ),
11 | )
12 |
--------------------------------------------------------------------------------
/AlmostDone/When/src/main/kotlin/jetbrains/kotlin/course/almost/done/Main.kt:
--------------------------------------------------------------------------------
1 | package jetbrains.kotlin.course.almost.done
2 |
3 | fun trimPicture(picture: String) = picture.trimIndent()
4 |
5 | fun applyBordersFilter(picture: String): String = TODO("Not implemented yet")
6 |
7 | fun applySquaredFilter(picture: String): String = TODO("Not implemented yet")
8 |
9 | fun applyFilter(picture: String, filter: String): String {
10 | val trimmedPicture = trimPicture(picture)
11 | return when(filter) {
12 | "borders" -> applyBordersFilter(trimmedPicture)
13 | "squared" -> applySquaredFilter(trimmedPicture)
14 | else -> error("Unexpected filter")
15 | }
16 | }
17 |
18 | fun main() {
19 | // Uncomment this code on the last step of the game
20 |
21 | // photoshop()
22 | }
23 |
--------------------------------------------------------------------------------
/AlmostDone/When/src/main/kotlin/jetbrains/kotlin/course/almost/done/PreDefinedSymbols.kt:
--------------------------------------------------------------------------------
1 | @file:Suppress("MayBeConst")
2 |
3 | package jetbrains.kotlin.course.almost.done
4 |
5 | val borderSymbol = '#'
6 | val separator = ' '
7 | val newLineSymbol = System.lineSeparator()
8 |
9 | fun getPictureWidth(picture: String) = picture.lines().maxOfOrNull { it.length } ?: 0
10 |
11 | fun getPictureByName(name: String) = allImages[name]
12 |
13 | fun allPictures() = allImages.keys
14 |
--------------------------------------------------------------------------------
/AlmostDone/When/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: edu
2 | custom_name: Console Photoshop - applyFilter Function
3 | files:
4 | - name: test/Tests.kt
5 | visible: false
6 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/Images.kt
7 | visible: false
8 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/Main.kt
9 | visible: true
10 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/PreDefinedSymbols.kt
11 | visible: false
12 | - name: test/Methods.kt
13 | visible: false
14 | - name: test/MainClass.kt
15 | visible: false
16 | feedback_link: https://docs.google.com/forms/d/e/1FAIpQLScylICclQIi9_YDjO7iuyRITDLn0Qgzw_aLxKxiishKAbL0qg/viewform?usp=pp_url&entry.2103429047=Introduction/Almost+done/When
17 |
--------------------------------------------------------------------------------
/AlmostDone/When/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 2042704900
2 |
--------------------------------------------------------------------------------
/AlmostDone/When/test/MainClass.kt:
--------------------------------------------------------------------------------
1 | import org.jetbrains.academy.test.system.core.models.classes.TestClass
2 |
3 | internal val mainClass = TestClass(
4 | classPackage = "jetbrains.kotlin.course.almost.done",
5 | customMethods = listOf(
6 | trimPictureMethod,
7 | applyBordersFilterMethod,
8 | applySquaredFilterMethod,
9 | applyFilterMethod,
10 | )
11 | )
12 |
--------------------------------------------------------------------------------
/AlmostDone/applyBordersFilterFunction/src/main/kotlin/jetbrains/kotlin/course/almost/done/Main.kt:
--------------------------------------------------------------------------------
1 | package jetbrains.kotlin.course.almost.done
2 |
3 | fun trimPicture(picture: String) = picture.trimIndent()
4 |
5 | fun applyBordersFilter(picture: String): String = TODO("Not implemented yet")
6 |
7 | fun applySquaredFilter(picture: String): String = TODO("Not implemented yet")
8 |
9 | fun main() {
10 | // Uncomment this code on the last step of the game
11 |
12 | // photoshop()
13 | }
14 |
--------------------------------------------------------------------------------
/AlmostDone/applyBordersFilterFunction/src/main/kotlin/jetbrains/kotlin/course/almost/done/PreDefinedSymbols.kt:
--------------------------------------------------------------------------------
1 | @file:Suppress("MayBeConst")
2 |
3 | package jetbrains.kotlin.course.almost.done
4 |
5 | val borderSymbol = '#'
6 | val separator = ' '
7 | val newLineSymbol = System.lineSeparator()
8 |
9 | fun getPictureWidth(picture: String) = picture.lines().maxOfOrNull { it.length } ?: 0
10 |
11 | fun getPictureByName(name: String) = allImages[name]
12 |
13 | fun allPictures() = allImages.keys
14 |
--------------------------------------------------------------------------------
/AlmostDone/applyBordersFilterFunction/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: edu
2 | custom_name: Console Photoshop - Filter Functions
3 | files:
4 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/Main.kt
5 | visible: true
6 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/Images.kt
7 | visible: false
8 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/PreDefinedSymbols.kt
9 | visible: false
10 | - name: test/MainClass.kt
11 | visible: false
12 | - name: test/Methods.kt
13 | visible: false
14 | - name: test/Tests.kt
15 | visible: false
16 |
--------------------------------------------------------------------------------
/AlmostDone/applyBordersFilterFunction/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 1988905602
2 |
--------------------------------------------------------------------------------
/AlmostDone/applyBordersFilterFunction/test/MainClass.kt:
--------------------------------------------------------------------------------
1 | import org.jetbrains.academy.test.system.core.models.classes.TestClass
2 |
3 | internal val mainClass = TestClass(
4 | classPackage = "jetbrains.kotlin.course.almost.done",
5 | customMethods = listOf(
6 | trimPictureMethod,
7 | applyBordersFilterMethod,
8 | applySquaredFilterMethod
9 | )
10 | )
11 |
--------------------------------------------------------------------------------
/AlmostDone/applyBordersFilterFunction/test/Methods.kt:
--------------------------------------------------------------------------------
1 | import org.jetbrains.academy.test.system.core.models.TestKotlinType
2 | import org.jetbrains.academy.test.system.core.models.method.TestMethod
3 | import org.jetbrains.academy.test.system.core.models.variable.TestVariable
4 |
5 | internal val trimPictureMethod = TestMethod(
6 | "trimPicture", TestKotlinType("String"), listOf(
7 | TestVariable("picture", "String"),
8 | )
9 | )
10 |
11 | internal val applyBordersFilterMethod = TestMethod(
12 | "applyBordersFilter",
13 | TestKotlinType("String"),
14 | listOf(TestVariable("picture", "String")),
15 | )
16 |
17 | internal val applySquaredFilterMethod = TestMethod(
18 | "applySquaredFilter",
19 | TestKotlinType("String"),
20 | listOf(TestVariable("picture", "String")),
21 | )
22 |
--------------------------------------------------------------------------------
/AlmostDone/choosePictureFunction/src/main/kotlin/jetbrains/kotlin/course/almost/done/PreDefinedSymbols.kt:
--------------------------------------------------------------------------------
1 | @file:Suppress("MayBeConst")
2 |
3 | package jetbrains.kotlin.course.almost.done
4 |
5 | val borderSymbol = '#'
6 | val separator = ' '
7 | val newLineSymbol = System.lineSeparator()
8 |
9 | fun getPictureWidth(picture: String) = picture.lines().maxOfOrNull { it.length } ?: 0
10 |
11 | fun getPictureByName(name: String) = allImages[name]
12 |
13 | fun allPictures() = allImages.keys
14 |
--------------------------------------------------------------------------------
/AlmostDone/choosePictureFunction/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: edu
2 | custom_name: Console Photoshop - choosePicture Function
3 | files:
4 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/PreDefinedSymbols.kt
5 | visible: false
6 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/Main.kt
7 | visible: true
8 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/Images.kt
9 | visible: false
10 | - name: test/MainClass.kt
11 | visible: false
12 | - name: test/Methods.kt
13 | visible: false
14 | - name: test/PhotoshopTestsUtils.kt
15 | visible: false
16 | - name: test/Tests.kt
17 | visible: false
18 |
--------------------------------------------------------------------------------
/AlmostDone/choosePictureFunction/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 553514186
2 |
--------------------------------------------------------------------------------
/AlmostDone/choosePictureFunction/test/MainClass.kt:
--------------------------------------------------------------------------------
1 | import org.jetbrains.academy.test.system.core.models.classes.TestClass
2 |
3 | internal val mainClass = TestClass(
4 | classPackage = "jetbrains.kotlin.course.almost.done",
5 | customMethods = listOf(
6 | trimPictureMethod,
7 | applyBordersFilterMethod,
8 | applySquaredFilterMethod,
9 | applyFilterMethod,
10 | chooseFilterMethod,
11 | safeReadLineMethod,
12 | choosePictureMethod,
13 | )
14 | )
15 |
--------------------------------------------------------------------------------
/AlmostDone/errorFunction/src/main/kotlin/jetbrains/kotlin/course/almost/done/Main.kt:
--------------------------------------------------------------------------------
1 | package jetbrains.kotlin.course.almost.done
2 |
3 | fun trimPicture(picture: String) = picture.trimIndent()
4 |
5 | fun applyBordersFilter(picture: String): String = TODO("Not implemented yet")
6 |
7 | fun applySquaredFilter(picture: String): String = TODO("Not implemented yet")
8 |
9 | fun main() {
10 | // Uncomment this code on the last step of the game
11 |
12 | // photoshop()
13 | }
14 |
--------------------------------------------------------------------------------
/AlmostDone/errorFunction/src/main/kotlin/jetbrains/kotlin/course/almost/done/PreDefinedSymbols.kt:
--------------------------------------------------------------------------------
1 | @file:Suppress("MayBeConst")
2 |
3 | package jetbrains.kotlin.course.almost.done
4 |
5 | val borderSymbol = '#'
6 | val separator = ' '
7 | val newLineSymbol = System.lineSeparator()
8 |
9 | fun getPictureWidth(picture: String) = picture.lines().maxOfOrNull { it.length } ?: 0
10 |
11 | fun getPictureByName(name: String) = allImages[name]
12 |
13 | fun allPictures() = allImages.keys
14 |
--------------------------------------------------------------------------------
/AlmostDone/errorFunction/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: theory
2 | custom_name: Console Photoshop - error Function
3 | files:
4 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/Main.kt
5 | visible: true
6 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/Images.kt
7 | visible: false
8 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/PreDefinedSymbols.kt
9 | visible: false
10 |
--------------------------------------------------------------------------------
/AlmostDone/errorFunction/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 1629287997
2 |
--------------------------------------------------------------------------------
/AlmostDone/errorFunction/task.md:
--------------------------------------------------------------------------------
1 | The `when` expression is useful in handling edge cases.
2 | For example, you can simply terminate the execution of the program
3 | and inform the user about errors.
4 | You can achieve this using the [`error`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/error.html) function:
5 | ```kotlin
6 | fun checkNumber(x: Int): Int {
7 | return when (x) {
8 | 0 -> { x + 5 }
9 | 10 -> { x - 5 }
10 | else -> error("Unexpected number")
11 | }
12 | }
13 | ```
14 |
--------------------------------------------------------------------------------
/AlmostDone/lesson-info.yaml:
--------------------------------------------------------------------------------
1 | type: framework
2 | custom_name: Almost done
3 | content:
4 | - Introduction
5 | - multiRowStringsTheory
6 | - MultiRowStrings
7 | - applyBordersFilterFunction
8 | - whenTheory
9 | - errorFunction
10 | - When
11 | - linesFunction
12 | - repeatFunction
13 | - stringBuilder
14 | - StringFunctions
15 | - StringFunctionsPartTwo
16 | - nullValue
17 | - nullSafetyTheory
18 | - safeReadLineFunction
19 | - NullSafety
20 | - letScopeFunction
21 | - choosePictureFunction
22 | - NullSafetyPartTwo
23 | - CompleteTheProject
24 | is_template_based: false
25 |
--------------------------------------------------------------------------------
/AlmostDone/lesson-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 815582437
2 |
--------------------------------------------------------------------------------
/AlmostDone/letScopeFunction/src/main/kotlin/jetbrains/kotlin/course/almost/done/PreDefinedSymbols.kt:
--------------------------------------------------------------------------------
1 | @file:Suppress("MayBeConst")
2 |
3 | package jetbrains.kotlin.course.almost.done
4 |
5 | val borderSymbol = '#'
6 | val separator = ' '
7 | val newLineSymbol = System.lineSeparator()
8 |
9 | fun getPictureWidth(picture: String) = picture.lines().maxOfOrNull { it.length } ?: 0
10 |
11 | fun getPictureByName(name: String) = allImages[name]
12 |
13 | fun allPictures() = allImages.keys
14 |
--------------------------------------------------------------------------------
/AlmostDone/letScopeFunction/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: theory
2 | custom_name: Console Photoshop - let Scope Function
3 | files:
4 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/PreDefinedSymbols.kt
5 | visible: false
6 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/Main.kt
7 | visible: true
8 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/Images.kt
9 | visible: false
10 |
--------------------------------------------------------------------------------
/AlmostDone/letScopeFunction/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 1609671976
2 |
--------------------------------------------------------------------------------
/AlmostDone/linesFunction/src/main/kotlin/jetbrains/kotlin/course/almost/done/Main.kt:
--------------------------------------------------------------------------------
1 | package jetbrains.kotlin.course.almost.done
2 |
3 | fun trimPicture(picture: String) = picture.trimIndent()
4 |
5 | fun applyBordersFilter(picture: String): String = TODO("Not implemented yet")
6 |
7 | fun applySquaredFilter(picture: String): String = TODO("Not implemented yet")
8 |
9 | fun applyFilter(picture: String, filter: String): String {
10 | val trimmedPicture = trimPicture(picture)
11 | return when(filter) {
12 | "borders" -> applyBordersFilter(trimmedPicture)
13 | "squared" -> applySquaredFilter(trimmedPicture)
14 | else -> error("Unexpected filter")
15 | }
16 | }
17 |
18 | fun main() {
19 | // Uncomment this code on the last step of the game
20 |
21 | // photoshop()
22 | }
23 |
--------------------------------------------------------------------------------
/AlmostDone/linesFunction/src/main/kotlin/jetbrains/kotlin/course/almost/done/PreDefinedSymbols.kt:
--------------------------------------------------------------------------------
1 | @file:Suppress("MayBeConst")
2 |
3 | package jetbrains.kotlin.course.almost.done
4 |
5 | val borderSymbol = '#'
6 | val separator = ' '
7 | val newLineSymbol = System.lineSeparator()
8 |
9 | fun getPictureWidth(picture: String) = picture.lines().maxOfOrNull { it.length } ?: 0
10 |
11 | fun getPictureByName(name: String) = allImages[name]
12 |
13 | fun allPictures() = allImages.keys
14 |
--------------------------------------------------------------------------------
/AlmostDone/linesFunction/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: theory
2 | custom_name: Console Photoshop - lines Function
3 | files:
4 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/Images.kt
5 | visible: false
6 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/Main.kt
7 | visible: true
8 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/PreDefinedSymbols.kt
9 | visible: false
10 |
--------------------------------------------------------------------------------
/AlmostDone/linesFunction/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 1298754091
2 |
--------------------------------------------------------------------------------
/AlmostDone/linesFunction/task.md:
--------------------------------------------------------------------------------
1 | When working with multiline strings, you can break them into lines and handle each one separately.
2 | This can be done using the [`lines`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/lines.html) function:
3 | ```kotlin
4 | """First line
5 | Second line
6 | """.lines()
7 | ```
8 | The string will be converted into a list with two strings: `First line` and `Second line`.
9 |
10 | This function is better than `split`, since it considers
11 | newline symbols from various operating systems under the hood:
12 |
13 | ```kotlin
14 | """First line
15 | Second line
16 | """.lines() // works on all OSs
17 | ```
18 | VS
19 | ```kotlin
20 | """First line
21 | Second line
22 | """.split("\n") // does not work on Windows
23 | ```
24 |
--------------------------------------------------------------------------------
/AlmostDone/multiRowStringsTheory/src/main/kotlin/jetbrains/kotlin/course/almost/done/Main.kt:
--------------------------------------------------------------------------------
1 | package jetbrains.kotlin.course.almost.done
2 |
3 | fun main() {
4 | // Uncomment this code on the last step of the game
5 |
6 | // photoshop()
7 | }
8 |
--------------------------------------------------------------------------------
/AlmostDone/multiRowStringsTheory/src/main/kotlin/jetbrains/kotlin/course/almost/done/PreDefinedSymbols.kt:
--------------------------------------------------------------------------------
1 | @file:Suppress("MayBeConst")
2 |
3 | package jetbrains.kotlin.course.almost.done
4 |
5 | val borderSymbol = '#'
6 | val separator = ' '
7 | val newLineSymbol = System.lineSeparator()
8 |
9 | fun getPictureWidth(picture: String) = picture.lines().maxOfOrNull { it.length } ?: 0
10 |
11 | fun getPictureByName(name: String) = allImages[name]
12 |
13 | fun allPictures() = allImages.keys
14 |
--------------------------------------------------------------------------------
/AlmostDone/multiRowStringsTheory/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: theory
2 | custom_name: Console Photoshop - Multi Row Strings
3 | files:
4 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/Main.kt
5 | visible: true
6 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/Images.kt
7 | visible: false
8 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/PreDefinedSymbols.kt
9 | visible: false
10 |
--------------------------------------------------------------------------------
/AlmostDone/multiRowStringsTheory/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 965912956
2 |
--------------------------------------------------------------------------------
/AlmostDone/nullSafetyTheory/src/main/kotlin/jetbrains/kotlin/course/almost/done/PreDefinedSymbols.kt:
--------------------------------------------------------------------------------
1 | @file:Suppress("MayBeConst")
2 |
3 | package jetbrains.kotlin.course.almost.done
4 |
5 | val borderSymbol = '#'
6 | val separator = ' '
7 | val newLineSymbol = System.lineSeparator()
8 |
9 | fun getPictureWidth(picture: String) = picture.lines().maxOfOrNull { it.length } ?: 0
10 |
11 | fun getPictureByName(name: String) = allImages[name]
12 |
13 | fun allPictures() = allImages.keys
14 |
--------------------------------------------------------------------------------
/AlmostDone/nullSafetyTheory/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: theory
2 | custom_name: Console Photoshop - Null Safety
3 | files:
4 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/Main.kt
5 | visible: true
6 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/PreDefinedSymbols.kt
7 | visible: false
8 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/Images.kt
9 | visible: false
10 |
--------------------------------------------------------------------------------
/AlmostDone/nullSafetyTheory/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 230726355
2 |
--------------------------------------------------------------------------------
/AlmostDone/nullValue/src/main/kotlin/jetbrains/kotlin/course/almost/done/PreDefinedSymbols.kt:
--------------------------------------------------------------------------------
1 | @file:Suppress("MayBeConst")
2 |
3 | package jetbrains.kotlin.course.almost.done
4 |
5 | val borderSymbol = '#'
6 | val separator = ' '
7 | val newLineSymbol = System.lineSeparator()
8 |
9 | fun getPictureWidth(picture: String) = picture.lines().maxOfOrNull { it.length } ?: 0
10 |
11 | fun getPictureByName(name: String) = allImages[name]
12 |
13 | fun allPictures() = allImages.keys
14 |
--------------------------------------------------------------------------------
/AlmostDone/nullValue/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: theory
2 | custom_name: Console Photoshop - null Value
3 | files:
4 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/Main.kt
5 | visible: true
6 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/PreDefinedSymbols.kt
7 | visible: false
8 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/Images.kt
9 | visible: false
10 |
--------------------------------------------------------------------------------
/AlmostDone/nullValue/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 192844197
2 |
--------------------------------------------------------------------------------
/AlmostDone/nullValue/task.md:
--------------------------------------------------------------------------------
1 | When defining a type, you can specify that it could also have a special `null` value.
2 | It's a `null` reference, which doesn't refer to anything.
3 | We will delve into more details about this in the following parts of the course;
4 | for now, it is enough to know some basic things.
5 |
6 | To indicate that a type might be `null`, you should add `?` to the type, for example:
7 | ```kotlin
8 | // 'a' can be String or null
9 | var a: String? = null
10 | ```
11 |
12 | If a value can be `null`, then the various built-in functions that we talked about earlier
13 | cannot automatically work with such a value, for example:
14 | ```kotlin
15 | var a: String? = null
16 | a.length // INCORRECT!!
17 |
18 | var a: String = "text"
19 | a.length // CORRECT
20 | ```
21 |
--------------------------------------------------------------------------------
/AlmostDone/repeatFunction/src/main/kotlin/jetbrains/kotlin/course/almost/done/Main.kt:
--------------------------------------------------------------------------------
1 | package jetbrains.kotlin.course.almost.done
2 |
3 | fun trimPicture(picture: String) = picture.trimIndent()
4 |
5 | fun applyBordersFilter(picture: String): String = TODO("Not implemented yet")
6 |
7 | fun applySquaredFilter(picture: String): String = TODO("Not implemented yet")
8 |
9 | fun applyFilter(picture: String, filter: String): String {
10 | val trimmedPicture = trimPicture(picture)
11 | return when(filter) {
12 | "borders" -> applyBordersFilter(trimmedPicture)
13 | "squared" -> applySquaredFilter(trimmedPicture)
14 | else -> error("Unexpected filter")
15 | }
16 | }
17 |
18 | fun main() {
19 | // Uncomment this code on the last step of the game
20 |
21 | // photoshop()
22 | }
23 |
--------------------------------------------------------------------------------
/AlmostDone/repeatFunction/src/main/kotlin/jetbrains/kotlin/course/almost/done/PreDefinedSymbols.kt:
--------------------------------------------------------------------------------
1 | @file:Suppress("MayBeConst")
2 |
3 | package jetbrains.kotlin.course.almost.done
4 |
5 | val borderSymbol = '#'
6 | val separator = ' '
7 | val newLineSymbol = System.lineSeparator()
8 |
9 | fun getPictureWidth(picture: String) = picture.lines().maxOfOrNull { it.length } ?: 0
10 |
11 | fun getPictureByName(name: String) = allImages[name]
12 |
13 | fun allPictures() = allImages.keys
14 |
--------------------------------------------------------------------------------
/AlmostDone/repeatFunction/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: theory
2 | custom_name: Console Photoshop - repeat Function
3 | files:
4 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/Images.kt
5 | visible: false
6 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/Main.kt
7 | visible: true
8 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/PreDefinedSymbols.kt
9 | visible: false
10 |
--------------------------------------------------------------------------------
/AlmostDone/repeatFunction/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 1495658846
2 |
--------------------------------------------------------------------------------
/AlmostDone/repeatFunction/task.md:
--------------------------------------------------------------------------------
1 | To generate a string by repeating a symbol, you can use the [`repeat`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/repeat.html) function:
2 | ```kotlin
3 | "@".repeat(4)
4 | ```
5 | It will generate the following string: `@@@@`.
6 |
--------------------------------------------------------------------------------
/AlmostDone/safeReadLineFunction/src/main/kotlin/jetbrains/kotlin/course/almost/done/PreDefinedSymbols.kt:
--------------------------------------------------------------------------------
1 | @file:Suppress("MayBeConst")
2 |
3 | package jetbrains.kotlin.course.almost.done
4 |
5 | val borderSymbol = '#'
6 | val separator = ' '
7 | val newLineSymbol = System.lineSeparator()
8 |
9 | fun getPictureWidth(picture: String) = picture.lines().maxOfOrNull { it.length } ?: 0
10 |
11 | fun getPictureByName(name: String) = allImages[name]
12 |
13 | fun allPictures() = allImages.keys
14 |
--------------------------------------------------------------------------------
/AlmostDone/safeReadLineFunction/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: edu
2 | custom_name: Console Photoshop - safeReadLine Function
3 | files:
4 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/Main.kt
5 | visible: true
6 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/PreDefinedSymbols.kt
7 | visible: false
8 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/Images.kt
9 | visible: false
10 | - name: test/MainClass.kt
11 | visible: false
12 | - name: test/Methods.kt
13 | visible: false
14 | - name: test/PhotoshopTestsUtils.kt
15 | visible: false
16 | - name: test/Tests.kt
17 | visible: false
18 |
--------------------------------------------------------------------------------
/AlmostDone/safeReadLineFunction/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 2065245492
2 |
--------------------------------------------------------------------------------
/AlmostDone/safeReadLineFunction/test/MainClass.kt:
--------------------------------------------------------------------------------
1 | import org.jetbrains.academy.test.system.core.models.classes.TestClass
2 |
3 | internal val mainClass = TestClass(
4 | classPackage = "jetbrains.kotlin.course.almost.done",
5 | customMethods = listOf(
6 | trimPictureMethod,
7 | applyBordersFilterMethod,
8 | applySquaredFilterMethod,
9 | applyFilterMethod,
10 | safeReadLineMethod
11 | ),
12 | )
13 |
--------------------------------------------------------------------------------
/AlmostDone/stringBuilder/src/main/kotlin/jetbrains/kotlin/course/almost/done/Main.kt:
--------------------------------------------------------------------------------
1 | package jetbrains.kotlin.course.almost.done
2 |
3 | fun trimPicture(picture: String) = picture.trimIndent()
4 |
5 | fun applyBordersFilter(picture: String): String = TODO("Not implemented yet")
6 |
7 | fun applySquaredFilter(picture: String): String = TODO("Not implemented yet")
8 |
9 | fun applyFilter(picture: String, filter: String): String {
10 | val trimmedPicture = trimPicture(picture)
11 | return when(filter) {
12 | "borders" -> applyBordersFilter(trimmedPicture)
13 | "squared" -> applySquaredFilter(trimmedPicture)
14 | else -> error("Unexpected filter")
15 | }
16 | }
17 |
18 | fun main() {
19 | // Uncomment this code on the last step of the game
20 |
21 | // photoshop()
22 | }
23 |
--------------------------------------------------------------------------------
/AlmostDone/stringBuilder/src/main/kotlin/jetbrains/kotlin/course/almost/done/PreDefinedSymbols.kt:
--------------------------------------------------------------------------------
1 | @file:Suppress("MayBeConst")
2 |
3 | package jetbrains.kotlin.course.almost.done
4 |
5 | val borderSymbol = '#'
6 | val separator = ' '
7 | val newLineSymbol = System.lineSeparator()
8 |
9 | fun getPictureWidth(picture: String) = picture.lines().maxOfOrNull { it.length } ?: 0
10 |
11 | fun getPictureByName(name: String) = allImages[name]
12 |
13 | fun allPictures() = allImages.keys
14 |
--------------------------------------------------------------------------------
/AlmostDone/stringBuilder/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: theory
2 | custom_name: Console Photoshop - StringBuilder
3 | files:
4 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/Images.kt
5 | visible: false
6 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/Main.kt
7 | visible: true
8 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/PreDefinedSymbols.kt
9 | visible: false
10 |
--------------------------------------------------------------------------------
/AlmostDone/stringBuilder/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 223687468
2 |
--------------------------------------------------------------------------------
/AlmostDone/whenTheory/src/main/kotlin/jetbrains/kotlin/course/almost/done/Main.kt:
--------------------------------------------------------------------------------
1 | package jetbrains.kotlin.course.almost.done
2 |
3 | fun trimPicture(picture: String) = picture.trimIndent()
4 |
5 | fun applyBordersFilter(picture: String): String = TODO("Not implemented yet")
6 |
7 | fun applySquaredFilter(picture: String): String = TODO("Not implemented yet")
8 |
9 | fun main() {
10 | // Uncomment this code on the last step of the game
11 |
12 | // photoshop()
13 | }
14 |
--------------------------------------------------------------------------------
/AlmostDone/whenTheory/src/main/kotlin/jetbrains/kotlin/course/almost/done/PreDefinedSymbols.kt:
--------------------------------------------------------------------------------
1 | @file:Suppress("MayBeConst")
2 |
3 | package jetbrains.kotlin.course.almost.done
4 |
5 | val borderSymbol = '#'
6 | val separator = ' '
7 | val newLineSymbol = System.lineSeparator()
8 |
9 | fun getPictureWidth(picture: String) = picture.lines().maxOfOrNull { it.length } ?: 0
10 |
11 | fun getPictureByName(name: String) = allImages[name]
12 |
13 | fun allPictures() = allImages.keys
14 |
--------------------------------------------------------------------------------
/AlmostDone/whenTheory/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: theory
2 | custom_name: Console Photoshop - when Expression
3 | files:
4 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/Main.kt
5 | visible: true
6 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/Images.kt
7 | visible: false
8 | - name: src/main/kotlin/jetbrains/kotlin/course/almost/done/PreDefinedSymbols.kt
9 | visible: false
10 |
--------------------------------------------------------------------------------
/AlmostDone/whenTheory/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 957199675
2 |
--------------------------------------------------------------------------------
/Chat/askFirstQuestion/src/main/kotlin/jetbrains/kotlin/course/chat/Main.kt:
--------------------------------------------------------------------------------
1 | package jetbrains.kotlin.course.chat
2 |
3 | fun main() {
4 | println("Hello! I'm glad to meet you, let me get to know you better! What is your name?")
5 | val name = readlnOrNull()
6 | }
7 |
--------------------------------------------------------------------------------
/Chat/askFirstQuestion/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: edu
2 | custom_name: Chat - Ask First Question
3 | files:
4 | - name: src/main/kotlin/jetbrains/kotlin/course/chat/Main.kt
5 | visible: true
6 | - name: test/Tests.kt
7 | visible: false
8 |
--------------------------------------------------------------------------------
/Chat/askFirstQuestion/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 468192544
2 |
--------------------------------------------------------------------------------
/Chat/askFirstQuestion/task.md:
--------------------------------------------------------------------------------
1 | In this task, you will start implementing the project.
2 |
3 | ### Task
4 |
5 | Ask the user the first question: `Hello! I'm glad to meet you, let me get to know you better! What is your name?`,
6 | and then store the user's answer in a variable (you can use any variable name you choose).
7 |
8 | **Note**: to avoid typos, just copy the text from here and paste it into your code.
9 |
10 | If you have any difficulties, **hints will help you solve this task**.
11 |
12 | ----
13 |
14 | ### Hints
15 |
16 |
17 |
18 | To print a question, you can use the `println` function from the previous steps.
19 | Then, to store the user's input in a variable, you can use the `readlnOrNull` function.
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Chat/askFirstQuestion/test/Tests.kt:
--------------------------------------------------------------------------------
1 | import jetbrains.kotlin.course.chat.main
2 | import org.junit.jupiter.api.Assertions
3 | import org.junit.jupiter.api.Test
4 | import util.Util
5 | import util.Util.DEFAULT_USER_INPUT
6 | import util.runMainFunction
7 | import org.junit.jupiter.api.extension.ExtendWith
8 | import util.HandleNotImplementedError
9 | import util.HandleNotImplementedErrorExtension
10 |
11 | @HandleNotImplementedError
12 | @ExtendWith(HandleNotImplementedErrorExtension::class)
13 | class Test {
14 | @Test
15 | fun testSolution() {
16 | Assertions.assertEquals(
17 | "Hello! I'm glad to meet you, let me get to know you better! What is your name?${Util.newLineSeparator}",
18 | runMainFunction(::main, "$DEFAULT_USER_INPUT${Util.newLineSeparator}")
19 | )
20 | }
21 | }
--------------------------------------------------------------------------------
/Chat/askSecondQuestion/src/main/kotlin/jetbrains/kotlin/course/chat/Main.kt:
--------------------------------------------------------------------------------
1 | package jetbrains.kotlin.course.chat
2 |
3 | fun main() {
4 | println("Hello! I'm glad to meet you, let me get to know you better! What is your name?")
5 | val name = readlnOrNull()
6 | println("Nice to meet you, $name! My name is Kotlin Bot! I am a young programming language created in 2010. How old are you?")
7 | val age = readlnOrNull()
8 | }
9 |
--------------------------------------------------------------------------------
/Chat/askSecondQuestion/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: edu
2 | custom_name: Chat - Ask Second Question
3 | files:
4 | - name: src/main/kotlin/jetbrains/kotlin/course/chat/Main.kt
5 | visible: true
6 | - name: test/Tests.kt
7 | visible: false
8 |
--------------------------------------------------------------------------------
/Chat/askSecondQuestion/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 692295510
2 |
--------------------------------------------------------------------------------
/Chat/chatIntro/src/main/kotlin/jetbrains/kotlin/course/chat/Main.kt:
--------------------------------------------------------------------------------
1 | package jetbrains.kotlin.course.chat
2 |
3 | fun main() {
4 | // Write your solution here
5 | }
6 |
--------------------------------------------------------------------------------
/Chat/chatIntro/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: theory
2 | custom_name: Chat - Introduction
3 | files:
4 | - name: src/main/kotlin/jetbrains/kotlin/course/chat/Main.kt
5 | visible: true
6 |
--------------------------------------------------------------------------------
/Chat/chatIntro/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 619115895
2 |
--------------------------------------------------------------------------------
/Chat/completeTheProject/src/main/kotlin/jetbrains/kotlin/course/chat/Main.kt:
--------------------------------------------------------------------------------
1 | package jetbrains.kotlin.course.chat
2 |
3 | fun main() {
4 | println("Hello! I'm glad to meet you, let me get to know you better! What is your name?")
5 | val name = readlnOrNull()
6 | println("Nice to meet you, $name! My name is Kotlin Bot! I am a young programming language created in 2010. How old are you?")
7 | val age = readlnOrNull()
8 | println("$age is great! I hope you successfully complete this course! Anyone can learn programming at any age!")
9 | }
10 |
--------------------------------------------------------------------------------
/Chat/completeTheProject/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: edu
2 | custom_name: Chat - Complete The Project
3 | files:
4 | - name: src/main/kotlin/jetbrains/kotlin/course/chat/Main.kt
5 | visible: true
6 | - name: test/Tests.kt
7 | visible: false
8 |
9 |
--------------------------------------------------------------------------------
/Chat/completeTheProject/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 949232906
2 |
--------------------------------------------------------------------------------
/Chat/lesson-info.yaml:
--------------------------------------------------------------------------------
1 | type: framework
2 | custom_name: Chat
3 | content:
4 | - chatIntro
5 | - askFirstQuestion
6 | - askSecondQuestion
7 | - completeTheProject
8 | is_template_based: false
9 |
--------------------------------------------------------------------------------
/Chat/lesson-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 734671394
2 |
--------------------------------------------------------------------------------
/FeedbackSurvey/Survey/src/Main.kt:
--------------------------------------------------------------------------------
1 | fun main() {
2 | // Write your solution here
3 | }
4 |
--------------------------------------------------------------------------------
/FeedbackSurvey/Survey/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: theory
2 | files:
3 | - name: src/Main.kt
4 | visible: true
5 | feedback_link: https://docs.google.com/forms/d/e/1FAIpQLScylICclQIi9_YDjO7iuyRITDLn0Qgzw_aLxKxiishKAbL0qg/viewform?usp=pp_url&entry.2103429047=Introduction/Feedback+Survey/Survey
6 |
--------------------------------------------------------------------------------
/FeedbackSurvey/Survey/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 615480409
2 |
--------------------------------------------------------------------------------
/FeedbackSurvey/Survey/task.md:
--------------------------------------------------------------------------------
1 | # Feedback Survey
2 |
3 | Thank you for taking our Kotlin Onboarding: Introduction course!
4 | We would really appreciate it if you could take a few minutes to answer our survey.
5 | Your feedback will help us improve this and further parts of the course and make them more relevant for future students.
6 | The [survey](https://surveys.jetbrains.com/s3/kotlin-onboarding-feedback-survey?part=1) is anonymous and should take no more than 5 minutes to complete.
7 | Stay tuned for more parts of our course coming soon!
8 |
9 |
10 |
11 | If for some reason the survey link is unclickable, you can copy the full link here:
12 | https://surveys.jetbrains.com/s3/kotlin-onboarding-feedback-survey?part=1
13 |
14 |
8 |
9 | ### Task
10 |
11 | Print the following text using the `print` or `println` function:
12 | ```text
13 | Hello! I will ask you several questions.
14 | Please answer all of them and be honest with me!
15 | ```
16 |
17 | **Note**: to avoid typos, just copy the text from here and paste it into your code.
18 |
--------------------------------------------------------------------------------
/TheFirstDateWithProgramming/BuiltinFunctions/test/Tests.kt:
--------------------------------------------------------------------------------
1 | import jetbrains.kotlin.course.first.date.main
2 | import org.junit.jupiter.api.Assertions
3 | import org.junit.jupiter.api.Test
4 | import util.Util
5 | import util.runMainFunction
6 | import org.junit.jupiter.api.extension.ExtendWith
7 | import util.HandleNotImplementedError
8 | import util.HandleNotImplementedErrorExtension
9 |
10 | @HandleNotImplementedError
11 | @ExtendWith(HandleNotImplementedErrorExtension::class)
12 | class Test {
13 | @Test
14 | fun testSolution() {
15 | Assertions.assertEquals(
16 | "Hello! I will ask you several questions.${Util.newLineSeparator}" +
17 | "Please answer all of them and be honest with me!${Util.newLineSeparator}",
18 | runMainFunction(::main)
19 | )
20 | }
21 | }
--------------------------------------------------------------------------------
/TheFirstDateWithProgramming/CompleteTheProject/src/main/kotlin/jetbrains/kotlin/course/first/date/Main.kt:
--------------------------------------------------------------------------------
1 | package jetbrains.kotlin.course.first.date
2 |
3 | fun main() {
4 | println("Hello! I will ask you several questions.")
5 | println("Please answer all of them and be honest with me!")
6 | println("What is TROTEN?")
7 | val firstUserAnswer = readlnOrNull()
8 | println("How did you spend your graduation?")
9 | val secondUserAnswer = readlnOrNull()
10 | println("Why does a spider need eight legs?")
11 | val thirdUserAnswer = readlnOrNull()
12 | println("Now let's have fun!")
13 | println(firstQuestion)
14 | println(firstUserAnswer)
15 | println(secondQuestion)
16 | println(secondUserAnswer)
17 | println(thirdQuestion)
18 | println(thirdUserAnswer)
19 | }
20 |
--------------------------------------------------------------------------------
/TheFirstDateWithProgramming/CompleteTheProject/src/main/kotlin/jetbrains/kotlin/course/first/date/RealQuestions.kt:
--------------------------------------------------------------------------------
1 | @file:Suppress("TopLevelPropertyNaming")
2 |
3 | package jetbrains.kotlin.course.first.date
4 |
5 | const val firstQuestion = "What is Kotlin?"
6 | const val secondQuestion = "How was Kotlin invented?"
7 | const val thirdQuestion = "Why are you learning Kotlin?"
8 |
--------------------------------------------------------------------------------
/TheFirstDateWithProgramming/CompleteTheProject/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: edu
2 | custom_name: Story twister - Complete the Project
3 | files:
4 | - name: test/Tests.kt
5 | visible: false
6 | - name: src/main/kotlin/jetbrains/kotlin/course/first/date/Main.kt
7 | visible: true
8 | - name: src/main/kotlin/jetbrains/kotlin/course/first/date/RealQuestions.kt
9 | visible: true
10 | feedback_link: https://docs.google.com/forms/d/e/1FAIpQLScylICclQIi9_YDjO7iuyRITDLn0Qgzw_aLxKxiishKAbL0qg/viewform?usp=pp_url&entry.2103429047=Introduction/The+first+day+with+programming/Complete+the+Project
11 |
--------------------------------------------------------------------------------
/TheFirstDateWithProgramming/CompleteTheProject/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 1021356481
2 |
--------------------------------------------------------------------------------
/TheFirstDateWithProgramming/Introduction/src/main/kotlin/jetbrains/kotlin/course/first/date/Main.kt:
--------------------------------------------------------------------------------
1 | package jetbrains.kotlin.course.first.date
2 |
3 | fun main() {
4 | println("My first program!")
5 | }
6 |
--------------------------------------------------------------------------------
/TheFirstDateWithProgramming/Introduction/src/main/kotlin/jetbrains/kotlin/course/first/date/RealQuestions.kt:
--------------------------------------------------------------------------------
1 | @file:Suppress("TopLevelPropertyNaming")
2 |
3 | package jetbrains.kotlin.course.first.date
4 |
5 | const val firstQuestion = "What is Kotlin?"
6 | const val secondQuestion = "How was Kotlin invented?"
7 | const val thirdQuestion = "Why are you learning Kotlin?"
8 |
--------------------------------------------------------------------------------
/TheFirstDateWithProgramming/Introduction/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: theory
2 | custom_name: Story twister - Introduction
3 | files:
4 | - name: src/main/kotlin/jetbrains/kotlin/course/first/date/Main.kt
5 | visible: true
6 | - name: src/main/kotlin/jetbrains/kotlin/course/first/date/RealQuestions.kt
7 | visible: false
8 | feedback_link: https://docs.google.com/forms/d/e/1FAIpQLScylICclQIi9_YDjO7iuyRITDLn0Qgzw_aLxKxiishKAbL0qg/viewform?usp=pp_url&entry.2103429047=Introduction/The+first+day+with+programming/Introduction
9 |
--------------------------------------------------------------------------------
/TheFirstDateWithProgramming/Introduction/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 214162757
2 |
--------------------------------------------------------------------------------
/TheFirstDateWithProgramming/Introduction/task.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | ### Project description
6 |
7 | The project of this lesson is **Story twister**.
8 | The goal of this game is to ask the user several fake questions,
9 | remember the answers, and then reveal the real questions to build a fun story from these answers.
10 |
11 | ### Lesson topics
12 |
13 | - the entry point for a Kotlin program;
14 | - built-in functions for printing to console;
15 | - variables;
16 | - built-in functions for reading user input.
17 |
18 | ### Project example
19 |
20 | 
21 |
--------------------------------------------------------------------------------
/TheFirstDateWithProgramming/ProgramEntryPoint/src/main/kotlin/jetbrains/kotlin/course/first/date/Main.kt:
--------------------------------------------------------------------------------
1 | package jetbrains.kotlin.course.first.date
2 |
3 | fun main() {
4 | println("Hello!")
5 | }
6 |
--------------------------------------------------------------------------------
/TheFirstDateWithProgramming/ProgramEntryPoint/src/main/kotlin/jetbrains/kotlin/course/first/date/RealQuestions.kt:
--------------------------------------------------------------------------------
1 | @file:Suppress("TopLevelPropertyNaming")
2 |
3 | package jetbrains.kotlin.course.first.date
4 |
5 | const val firstQuestion = "What is Kotlin?"
6 | const val secondQuestion = "How was Kotlin invented?"
7 | const val thirdQuestion = "Why are you learning Kotlin?"
8 |
--------------------------------------------------------------------------------
/TheFirstDateWithProgramming/ProgramEntryPoint/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: edu
2 | custom_name: Story twister - First Kotlin Program
3 | files:
4 | - name: src/main/kotlin/jetbrains/kotlin/course/first/date/Main.kt
5 | visible: true
6 | - name: test/Tests.kt
7 | visible: false
8 | - name: src/main/kotlin/jetbrains/kotlin/course/first/date/RealQuestions.kt
9 | visible: false
10 | feedback_link: https://docs.google.com/forms/d/e/1FAIpQLScylICclQIi9_YDjO7iuyRITDLn0Qgzw_aLxKxiishKAbL0qg/viewform?usp=pp_url&entry.2103429047=Introduction/The+first+day+with+programming/Program+entry+point
11 |
--------------------------------------------------------------------------------
/TheFirstDateWithProgramming/ProgramEntryPoint/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 1412191977
2 |
--------------------------------------------------------------------------------
/TheFirstDateWithProgramming/ProgramEntryPoint/task.md:
--------------------------------------------------------------------------------
1 | It's time to write your first program in Kotlin!
2 |
3 | ### Task
4 |
5 | Change the output text into `Hello!` and run the program.
6 |
7 |
8 |
9 | To run your program, you need to open the `Main.kt` file and click on the **green triangle** near the `main` function.
10 | Then, the output of the program will be shown in the console:
11 |
12 | 
13 |
14 |
15 |
--------------------------------------------------------------------------------
/TheFirstDateWithProgramming/ProgramEntryPoint/test/Tests.kt:
--------------------------------------------------------------------------------
1 | import jetbrains.kotlin.course.first.date.main
2 | import org.junit.jupiter.api.Assertions
3 | import org.junit.jupiter.api.Test
4 | import org.junit.jupiter.api.extension.ExtendWith
5 | import util.HandleNotImplementedError
6 | import util.HandleNotImplementedErrorExtension
7 | import util.Util
8 | import util.runMainFunction
9 |
10 | @HandleNotImplementedError
11 | @ExtendWith(HandleNotImplementedErrorExtension::class)
12 | class Test {
13 | @Test
14 | fun testSolution() {
15 | Assertions.assertEquals("Hello!${Util.newLineSeparator}", runMainFunction(::main))
16 | }
17 | }
--------------------------------------------------------------------------------
/TheFirstDateWithProgramming/ReadUserInput/src/main/kotlin/jetbrains/kotlin/course/first/date/Main.kt:
--------------------------------------------------------------------------------
1 | package jetbrains.kotlin.course.first.date
2 |
3 | fun main() {
4 | println("Hello! I will ask you several questions.")
5 | println("Please answer all of them and be honest with me!")
6 | println("What is TROTEN?")
7 | val firstUserAnswer = readlnOrNull()
8 | println("How did you spend your graduation?")
9 | val secondUserAnswer = readlnOrNull()
10 | println("Why does a spider need eight legs?")
11 | val thirdUserAnswer = readlnOrNull()
12 | }
13 |
--------------------------------------------------------------------------------
/TheFirstDateWithProgramming/ReadUserInput/src/main/kotlin/jetbrains/kotlin/course/first/date/RealQuestions.kt:
--------------------------------------------------------------------------------
1 | @file:Suppress("TopLevelPropertyNaming")
2 |
3 | package jetbrains.kotlin.course.first.date
4 |
5 | const val firstQuestion = "What is Kotlin?"
6 | const val secondQuestion = "How was Kotlin invented?"
7 | const val thirdQuestion = "Why are you learning Kotlin?"
8 |
--------------------------------------------------------------------------------
/TheFirstDateWithProgramming/ReadUserInput/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: edu
2 | custom_name: Story twister - Read user input, Practice
3 | files:
4 | - name: test/Tests.kt
5 | visible: false
6 | - name: src/main/kotlin/jetbrains/kotlin/course/first/date/Main.kt
7 | visible: true
8 | - name: src/main/kotlin/jetbrains/kotlin/course/first/date/RealQuestions.kt
9 | visible: false
10 | feedback_link: https://docs.google.com/forms/d/e/1FAIpQLScylICclQIi9_YDjO7iuyRITDLn0Qgzw_aLxKxiishKAbL0qg/viewform?usp=pp_url&entry.2103429047=Introduction/The+first+day+with+programming/Read+User+Input
11 |
--------------------------------------------------------------------------------
/TheFirstDateWithProgramming/ReadUserInput/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 172830079
2 |
--------------------------------------------------------------------------------
/TheFirstDateWithProgramming/Variables/src/main/kotlin/jetbrains/kotlin/course/first/date/Main.kt:
--------------------------------------------------------------------------------
1 | package jetbrains.kotlin.course.first.date
2 |
3 | fun main() {
4 | println("Hello! I will ask you several questions.")
5 | println("Please answer all of them and be honest with me!")
6 | val firstUserAnswer = ""
7 | val secondUserAnswer = ""
8 | val thirdUserAnswer = ""
9 | }
10 |
--------------------------------------------------------------------------------
/TheFirstDateWithProgramming/Variables/src/main/kotlin/jetbrains/kotlin/course/first/date/RealQuestions.kt:
--------------------------------------------------------------------------------
1 | @file:Suppress("TopLevelPropertyNaming")
2 |
3 | package jetbrains.kotlin.course.first.date
4 |
5 | const val firstQuestion = "What is Kotlin?"
6 | const val secondQuestion = "How was Kotlin invented?"
7 | const val thirdQuestion = "Why are you learning Kotlin?"
8 |
--------------------------------------------------------------------------------
/TheFirstDateWithProgramming/Variables/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: edu
2 | custom_name: Story twister - Variables, Practice
3 | files:
4 | - name: test/Tests.kt
5 | visible: false
6 | - name: src/main/kotlin/jetbrains/kotlin/course/first/date/Main.kt
7 | visible: true
8 | - name: src/main/kotlin/jetbrains/kotlin/course/first/date/RealQuestions.kt
9 | visible: false
10 | feedback_link: https://docs.google.com/forms/d/e/1FAIpQLScylICclQIi9_YDjO7iuyRITDLn0Qgzw_aLxKxiishKAbL0qg/viewform?usp=pp_url&entry.2103429047=Introduction/The+first+day+with+programming/Variables
11 |
--------------------------------------------------------------------------------
/TheFirstDateWithProgramming/Variables/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 410448577
2 |
--------------------------------------------------------------------------------
/TheFirstDateWithProgramming/Variables/task.md:
--------------------------------------------------------------------------------
1 | In this task, we will add variables to store the user's answers.
2 |
3 | ### Task
4 |
5 | Add empty `String` variables to hold the user's answers, named
6 | _firstUserAnswer_, _secondUserAnswer_, and _thirdUserAnswer_.
7 |
8 | If you have any difficulties, **hints will help you solve this task**.
9 |
10 | ----
11 |
12 | ### Hints
13 |
14 |
15 |
16 | In the current task, it is better to use the `val` keyword, since we will just _save_ values from the user
17 | into the variables and will not change them afterwards.
18 |
19 |
20 |
--------------------------------------------------------------------------------
/TheFirstDateWithProgramming/builtinFunctionsTheory/src/main/kotlin/jetbrains/kotlin/course/first/date/Main.kt:
--------------------------------------------------------------------------------
1 | package jetbrains.kotlin.course.first.date
2 |
3 | fun main() {
4 | println("Hello!")
5 | }
6 |
--------------------------------------------------------------------------------
/TheFirstDateWithProgramming/builtinFunctionsTheory/src/main/kotlin/jetbrains/kotlin/course/first/date/RealQuestions.kt:
--------------------------------------------------------------------------------
1 | @file:Suppress("TopLevelPropertyNaming")
2 |
3 | package jetbrains.kotlin.course.first.date
4 |
5 | const val firstQuestion = "What is Kotlin?"
6 | const val secondQuestion = "How was Kotlin invented?"
7 | const val thirdQuestion = "Why are you learning Kotlin?"
8 |
--------------------------------------------------------------------------------
/TheFirstDateWithProgramming/builtinFunctionsTheory/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: theory
2 | custom_name: Story twister - Built-in Functions
3 | files:
4 | - name: src/main/kotlin/jetbrains/kotlin/course/first/date/Main.kt
5 | visible: true
6 | - name: src/main/kotlin/jetbrains/kotlin/course/first/date/RealQuestions.kt
7 | visible: false
8 |
--------------------------------------------------------------------------------
/TheFirstDateWithProgramming/builtinFunctionsTheory/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 563522277
2 |
--------------------------------------------------------------------------------
/TheFirstDateWithProgramming/comments/src/main/kotlin/jetbrains/kotlin/course/first/date/Main.kt:
--------------------------------------------------------------------------------
1 | package jetbrains.kotlin.course.first.date
2 |
3 | fun main() {
4 | println("Hello! I will ask you several questions.")
5 | println("Please answer all of them and be honest with me!")
6 | println("What is TROTEN?")
7 | val firstUserAnswer = readlnOrNull()
8 | println("How did you spend your graduation?")
9 | val secondUserAnswer = readlnOrNull()
10 | println("Why does a spider need eight legs?")
11 | val thirdUserAnswer = readlnOrNull()
12 | }
13 |
--------------------------------------------------------------------------------
/TheFirstDateWithProgramming/comments/src/main/kotlin/jetbrains/kotlin/course/first/date/RealQuestions.kt:
--------------------------------------------------------------------------------
1 | @file:Suppress("TopLevelPropertyNaming")
2 |
3 | package jetbrains.kotlin.course.first.date
4 |
5 | const val firstQuestion = "What is Kotlin?"
6 | const val secondQuestion = "How was Kotlin invented?"
7 | const val thirdQuestion = "Why are you learning Kotlin?"
8 |
--------------------------------------------------------------------------------
/TheFirstDateWithProgramming/comments/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: theory
2 | custom_name: Story twister - Comments
3 | files:
4 | - name: src/main/kotlin/jetbrains/kotlin/course/first/date/Main.kt
5 | visible: true
6 | - name: src/main/kotlin/jetbrains/kotlin/course/first/date/RealQuestions.kt
7 | visible: false
8 |
--------------------------------------------------------------------------------
/TheFirstDateWithProgramming/comments/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 398217788
2 |
--------------------------------------------------------------------------------
/TheFirstDateWithProgramming/comments/task.md:
--------------------------------------------------------------------------------
1 | Congratulations, you've almost finished your first project!
2 |
3 | Let me share a little trick on how you can write [comments](https://kotlinlang.org/docs/basic-syntax.html#comments)
4 | for other developers (or for yourself) in your code.
5 | To do this, use a double slash at the beginning of the code line:
6 | ```kotlin
7 | fun main() {
8 | // My comment, I can write whatever I want here
9 | }
10 | ```
11 | Comments are usually left for the most complex parts of code,
12 | making it easier to understand their functions later on.
13 |
--------------------------------------------------------------------------------
/TheFirstDateWithProgramming/lesson-info.yaml:
--------------------------------------------------------------------------------
1 | type: framework
2 | custom_name: The first date with programming
3 | content:
4 | - Introduction
5 | - programEntryPointTheory
6 | - ProgramEntryPoint
7 | - builtinFunctionsTheory
8 | - BuiltinFunctions
9 | - variablesTheory
10 | - Variables
11 | - readUserInputTheory
12 | - ReadUserInput
13 | - comments
14 | - CompleteTheProject
15 | is_template_based: false
16 |
--------------------------------------------------------------------------------
/TheFirstDateWithProgramming/lesson-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 599627186
2 |
--------------------------------------------------------------------------------
/TheFirstDateWithProgramming/programEntryPointTheory/src/main/kotlin/jetbrains/kotlin/course/first/date/Main.kt:
--------------------------------------------------------------------------------
1 | package jetbrains.kotlin.course.first.date
2 |
3 | fun main() {
4 | println("My first program!")
5 | }
6 |
--------------------------------------------------------------------------------
/TheFirstDateWithProgramming/programEntryPointTheory/src/main/kotlin/jetbrains/kotlin/course/first/date/RealQuestions.kt:
--------------------------------------------------------------------------------
1 | @file:Suppress("TopLevelPropertyNaming")
2 |
3 | package jetbrains.kotlin.course.first.date
4 |
5 | const val firstQuestion = "What is Kotlin?"
6 | const val secondQuestion = "How was Kotlin invented?"
7 | const val thirdQuestion = "Why are you learning Kotlin?"
8 |
--------------------------------------------------------------------------------
/TheFirstDateWithProgramming/programEntryPointTheory/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: theory
2 | custom_name: Story twister - Program Entry Point
3 | files:
4 | - name: src/main/kotlin/jetbrains/kotlin/course/first/date/Main.kt
5 | visible: true
6 | - name: src/main/kotlin/jetbrains/kotlin/course/first/date/RealQuestions.kt
7 | visible: false
8 |
--------------------------------------------------------------------------------
/TheFirstDateWithProgramming/programEntryPointTheory/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 1843240451
2 |
--------------------------------------------------------------------------------
/TheFirstDateWithProgramming/readUserInputTheory/src/main/kotlin/jetbrains/kotlin/course/first/date/Main.kt:
--------------------------------------------------------------------------------
1 | package jetbrains.kotlin.course.first.date
2 |
3 | fun main() {
4 | println("Hello! I will ask you several questions.")
5 | println("Please answer all of them and be honest with me!")
6 | val firstUserAnswer = ""
7 | val secondUserAnswer = ""
8 | val thirdUserAnswer = ""
9 | }
10 |
--------------------------------------------------------------------------------
/TheFirstDateWithProgramming/readUserInputTheory/src/main/kotlin/jetbrains/kotlin/course/first/date/RealQuestions.kt:
--------------------------------------------------------------------------------
1 | @file:Suppress("TopLevelPropertyNaming")
2 |
3 | package jetbrains.kotlin.course.first.date
4 |
5 | const val firstQuestion = "What is Kotlin?"
6 | const val secondQuestion = "How was Kotlin invented?"
7 | const val thirdQuestion = "Why are you learning Kotlin?"
8 |
--------------------------------------------------------------------------------
/TheFirstDateWithProgramming/readUserInputTheory/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: theory
2 | custom_name: Story twister - Read user input, Theory
3 | files:
4 | - name: src/main/kotlin/jetbrains/kotlin/course/first/date/Main.kt
5 | visible: true
6 | - name: src/main/kotlin/jetbrains/kotlin/course/first/date/RealQuestions.kt
7 | visible: false
8 |
--------------------------------------------------------------------------------
/TheFirstDateWithProgramming/readUserInputTheory/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 378596203
2 |
--------------------------------------------------------------------------------
/TheFirstDateWithProgramming/variablesTheory/src/main/kotlin/jetbrains/kotlin/course/first/date/Main.kt:
--------------------------------------------------------------------------------
1 | package jetbrains.kotlin.course.first.date
2 |
3 | fun main() {
4 | println("Hello! I will ask you several questions.")
5 | println("Please answer all of them and be honest with me!")
6 | }
7 |
--------------------------------------------------------------------------------
/TheFirstDateWithProgramming/variablesTheory/src/main/kotlin/jetbrains/kotlin/course/first/date/RealQuestions.kt:
--------------------------------------------------------------------------------
1 | @file:Suppress("TopLevelPropertyNaming")
2 |
3 | package jetbrains.kotlin.course.first.date
4 |
5 | const val firstQuestion = "What is Kotlin?"
6 | const val secondQuestion = "How was Kotlin invented?"
7 | const val thirdQuestion = "Why are you learning Kotlin?"
8 |
--------------------------------------------------------------------------------
/TheFirstDateWithProgramming/variablesTheory/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: theory
2 | custom_name: Story twister - Variables, Theory
3 | files:
4 | - name: src/main/kotlin/jetbrains/kotlin/course/first/date/Main.kt
5 | visible: true
6 | - name: src/main/kotlin/jetbrains/kotlin/course/first/date/RealQuestions.kt
7 | visible: false
8 |
--------------------------------------------------------------------------------
/TheFirstDateWithProgramming/variablesTheory/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 604688510
2 |
--------------------------------------------------------------------------------
/WarmUp/Collections/src/main/kotlin/jetbrains/kotlin/course/warmup/Util.kt:
--------------------------------------------------------------------------------
1 | package jetbrains.kotlin.course.warmup
2 |
3 | fun safeReadLine() = readlnOrNull() ?: error("Your input is incorrect, sorry")
4 |
5 | val newLineSymbol: String = System.lineSeparator()
6 |
--------------------------------------------------------------------------------
/WarmUp/Collections/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: edu
2 | custom_name: Mastermind - countExactMatches Function
3 | files:
4 | - name: src/main/kotlin/jetbrains/kotlin/course/warmup/Main.kt
5 | visible: true
6 | - name: test/Tests.kt
7 | visible: false
8 | - name: src/main/kotlin/jetbrains/kotlin/course/warmup/Util.kt
9 | visible: false
10 | - name: test/Methods.kt
11 | visible: false
12 | - name: test/MainClass.kt
13 | visible: false
14 | feedback_link: https://docs.google.com/forms/d/e/1FAIpQLScylICclQIi9_YDjO7iuyRITDLn0Qgzw_aLxKxiishKAbL0qg/viewform?usp=pp_url&entry.2103429047=Introduction/Warm+up/Collections
15 |
--------------------------------------------------------------------------------
/WarmUp/Collections/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 1651787790
2 |
--------------------------------------------------------------------------------
/WarmUp/Collections/test/MainClass.kt:
--------------------------------------------------------------------------------
1 | package jetbrains.kotlin.course.warmup
2 |
3 | import org.jetbrains.academy.test.system.core.models.classes.TestClass
4 |
5 | internal val mainClass = TestClass(
6 | classPackage = "jetbrains.kotlin.course.warmup",
7 | customMethods = listOf(
8 | isCompleteMethod,
9 | countExactMatchesMethod,
10 | generateSecretMethod,
11 | getGameRulesMethod,
12 | countPartialMatchesMethod,
13 | playGameMethod
14 | ),
15 | )
16 |
--------------------------------------------------------------------------------
/WarmUp/CollectionsPartTwo/src/main/kotlin/jetbrains/kotlin/course/warmup/Util.kt:
--------------------------------------------------------------------------------
1 | package jetbrains.kotlin.course.warmup
2 |
3 | fun safeReadLine() = readlnOrNull() ?: error("Your input is incorrect, sorry")
4 |
5 | val newLineSymbol: String = System.lineSeparator()
6 |
--------------------------------------------------------------------------------
/WarmUp/CollectionsPartTwo/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: edu
2 | custom_name: Mastermind - countAllMatches Function
3 | files:
4 | - name: src/main/kotlin/jetbrains/kotlin/course/warmup/Util.kt
5 | visible: false
6 | - name: test/Tests.kt
7 | visible: false
8 | - name: src/main/kotlin/jetbrains/kotlin/course/warmup/Main.kt
9 | visible: true
10 | - name: test/Methods.kt
11 | visible: false
12 | - name: test/MainClass.kt
13 | visible: false
14 | feedback_link: https://docs.google.com/forms/d/e/1FAIpQLScylICclQIi9_YDjO7iuyRITDLn0Qgzw_aLxKxiishKAbL0qg/viewform?usp=pp_url&entry.2103429047=Introduction/Warm+up/Collections+part+two
15 |
--------------------------------------------------------------------------------
/WarmUp/CollectionsPartTwo/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 912657372
2 |
--------------------------------------------------------------------------------
/WarmUp/CollectionsPartTwo/test/MainClass.kt:
--------------------------------------------------------------------------------
1 | import org.jetbrains.academy.test.system.core.models.classes.TestClass
2 |
3 | internal val mainClass = TestClass(
4 | classPackage = "jetbrains.kotlin.course.warmup",
5 | customMethods = listOf(
6 | isCompleteMethod,
7 | countExactMatchesMethod,
8 | countPartialMatchesMethod,
9 | generateSecretMethod,
10 | getGameRulesMethod,
11 | countAllMatches,
12 | playGameMethod
13 | ),
14 | )
15 |
--------------------------------------------------------------------------------
/WarmUp/CompleteTheProject/src/main/kotlin/jetbrains/kotlin/course/warmup/Util.kt:
--------------------------------------------------------------------------------
1 | package jetbrains.kotlin.course.warmup
2 |
3 | fun safeReadLine() = readlnOrNull() ?: error("Your input is incorrect, sorry")
4 |
5 | val newLineSymbol: String = System.lineSeparator()
6 |
--------------------------------------------------------------------------------
/WarmUp/CompleteTheProject/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: edu
2 | custom_name: Mastermind - Finish Base Game
3 | files:
4 | - name: src/main/kotlin/jetbrains/kotlin/course/warmup/Main.kt
5 | visible: true
6 | - name: src/main/kotlin/jetbrains/kotlin/course/warmup/Util.kt
7 | visible: true
8 | - name: test/MainClass.kt
9 | visible: false
10 | - name: test/MastermindTestUtil.kt
11 | visible: false
12 | - name: test/Methods.kt
13 | visible: false
14 | - name: test/Tests.kt
15 | visible: false
16 | feedback_link: https://docs.google.com/forms/d/e/1FAIpQLScylICclQIi9_YDjO7iuyRITDLn0Qgzw_aLxKxiishKAbL0qg/viewform?usp=pp_url&entry.2103429047=Introduction/Warm+up/Finish+the+game
17 |
--------------------------------------------------------------------------------
/WarmUp/CompleteTheProject/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 1278662430
2 |
--------------------------------------------------------------------------------
/WarmUp/CompleteTheProject/task.md:
--------------------------------------------------------------------------------
1 | Hurrah! In this task we will finish the base game.
2 |
3 | ### Task
4 |
5 | Modify the `playGame` function: add a variable that counts the number of the user's attempts.
6 | We need to count the attempts from zero, which means the user can try to guess the secret `maxAttemptsCount` + 1 times.
7 | The `playGame` function should print the following messages to inform the user: `Sorry, you lost! :( My word is ` and `Congratulations! You guessed it!`.
8 | Use `isWon` and `isLost` from the previous steps inside the loop to check the current game state.
9 |
10 | Before each question to the user please use `Please input your guess. It should be of length .` text.
11 |
12 | **Note**: to avoid typos just copy the text from here and paste into your code.
13 |
14 |
--------------------------------------------------------------------------------
/WarmUp/CompleteTheProject/test/MainClass.kt:
--------------------------------------------------------------------------------
1 | import org.jetbrains.academy.test.system.core.models.classes.TestClass
2 |
3 | internal val mainClass = TestClass(
4 | classPackage = "jetbrains.kotlin.course.warmup",
5 | customMethods = listOf(
6 | isCompleteMethod,
7 | countExactMatchesMethod,
8 | countPartialMatchesMethod,
9 | isWinMethod,
10 | isLostMethod,
11 | generateSecretMethod,
12 | printRoundResultsMethod,
13 | getGameRulesMethod,
14 | playGameMethod
15 | ),
16 | )
17 |
--------------------------------------------------------------------------------
/WarmUp/CustomFunctions/src/main/kotlin/jetbrains/kotlin/course/warmup/Util.kt:
--------------------------------------------------------------------------------
1 | package jetbrains.kotlin.course.warmup
2 |
3 | fun safeReadLine() = readlnOrNull() ?: error("Your input is incorrect, sorry")
4 |
5 | val newLineSymbol: String = System.lineSeparator()
6 |
--------------------------------------------------------------------------------
/WarmUp/CustomFunctions/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: edu
2 | custom_name: Mastermind - Add First Custom Functions
3 | files:
4 | - name: src/main/kotlin/jetbrains/kotlin/course/warmup/Main.kt
5 | visible: true
6 | - name: test/Tests.kt
7 | visible: false
8 | - name: src/main/kotlin/jetbrains/kotlin/course/warmup/Util.kt
9 | visible: false
10 | - name: test/Methods.kt
11 | visible: false
12 | - name: test/MainClass.kt
13 | visible: false
14 | feedback_link: https://docs.google.com/forms/d/e/1FAIpQLScylICclQIi9_YDjO7iuyRITDLn0Qgzw_aLxKxiishKAbL0qg/viewform?usp=pp_url&entry.2103429047=Introduction/Warm+up/Custom+functions
15 |
--------------------------------------------------------------------------------
/WarmUp/CustomFunctions/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 21668245
2 |
--------------------------------------------------------------------------------
/WarmUp/CustomFunctions/test/MainClass.kt:
--------------------------------------------------------------------------------
1 | import org.jetbrains.academy.test.system.core.models.classes.TestClass
2 |
3 | internal val mainClass = TestClass(
4 | classPackage = "jetbrains.kotlin.course.warmup",
5 | customMethods = listOf(
6 | getGameRulesMethod,
7 | generateSecretMethod,
8 | countPartialMatchesMethod,
9 | countExactMatchesMethod,
10 | ),
11 | )
12 |
--------------------------------------------------------------------------------
/WarmUp/If/src/main/kotlin/jetbrains/kotlin/course/warmup/Util.kt:
--------------------------------------------------------------------------------
1 | package jetbrains.kotlin.course.warmup
2 |
3 | fun safeReadLine() = readlnOrNull() ?: error("Your input is incorrect, sorry")
4 |
5 | val newLineSymbol: String = System.lineSeparator()
6 |
--------------------------------------------------------------------------------
/WarmUp/If/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: edu
2 | custom_name: Mastermind - Finish isComplete Function
3 | files:
4 | - name: src/main/kotlin/jetbrains/kotlin/course/warmup/Main.kt
5 | visible: true
6 | - name: test/Tests.kt
7 | visible: false
8 | - name: src/main/kotlin/jetbrains/kotlin/course/warmup/Util.kt
9 | visible: false
10 | - name: test/Methods.kt
11 | visible: false
12 | - name: test/MainClass.kt
13 | visible: false
14 | feedback_link: https://docs.google.com/forms/d/e/1FAIpQLScylICclQIi9_YDjO7iuyRITDLn0Qgzw_aLxKxiishKAbL0qg/viewform?usp=pp_url&entry.2103429047=Introduction/Warm+up/If
15 |
--------------------------------------------------------------------------------
/WarmUp/If/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 13109812
2 |
--------------------------------------------------------------------------------
/WarmUp/If/task.md:
--------------------------------------------------------------------------------
1 | In this task we will implement the `isComplete` function, since the current implementation always returns `true`.
2 |
3 | ### Task
4 |
5 | Implement the `isComplete` function. It should return `true`
6 | if `secret` and `guess` are the same and `false` otherwise.
7 |
8 | If you have any difficulties, **hints will help you solve this task**.
9 |
10 | ----
11 |
12 | ### Hints
13 |
14 |
15 |
16 | If you compare two variables to get a `Boolean` result, you can use the short notation.
17 | For example, the following code:
18 | ```
19 | fun isNotEqual(a: Int, b: Int) = if (a != b) {
20 | true
21 | } else {
22 | false
23 | }
24 | ```
25 | can be replaced with this one:
26 | ```
27 | fun isNotEqual(a: Int, b: Int) = a != b
28 | ```
29 |
30 |
--------------------------------------------------------------------------------
/WarmUp/If/test/MainClass.kt:
--------------------------------------------------------------------------------
1 | import org.jetbrains.academy.test.system.core.models.classes.TestClass
2 |
3 | internal val mainClass = TestClass(
4 | classPackage = "jetbrains.kotlin.course.warmup",
5 | customMethods = listOf(
6 | isCompleteMethod,
7 | playGameMethod,
8 | getGameRulesMethod,
9 | generateSecretMethod,
10 | countPartialMatchesMethod,
11 | countExactMatches,
12 | ),
13 | )
14 |
--------------------------------------------------------------------------------
/WarmUp/Introduction/src/main/kotlin/jetbrains/kotlin/course/warmup/Util.kt:
--------------------------------------------------------------------------------
1 | package jetbrains.kotlin.course.warmup
2 |
3 | fun safeReadLine() = readlnOrNull() ?: error("Your input is incorrect, sorry")
4 |
5 | val newLineSymbol: String = System.lineSeparator()
6 |
--------------------------------------------------------------------------------
/WarmUp/Introduction/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: theory
2 | custom_name: Mastermind - Introduction
3 | files:
4 | - name: src/main/kotlin/jetbrains/kotlin/course/warmup/Main.kt
5 | visible: true
6 | - name: src/main/kotlin/jetbrains/kotlin/course/warmup/Util.kt
7 | visible: false
8 | feedback_link: https://docs.google.com/forms/d/e/1FAIpQLScylICclQIi9_YDjO7iuyRITDLn0Qgzw_aLxKxiishKAbL0qg/viewform?usp=pp_url&entry.2103429047=Introduction/Warm+up/Introduction
9 |
--------------------------------------------------------------------------------
/WarmUp/Introduction/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 1444969308
2 |
--------------------------------------------------------------------------------
/WarmUp/Loops/src/main/kotlin/jetbrains/kotlin/course/warmup/Util.kt:
--------------------------------------------------------------------------------
1 | package jetbrains.kotlin.course.warmup
2 |
3 | fun safeReadLine() = readlnOrNull() ?: error("Your input is incorrect, sorry")
4 |
5 | val newLineSymbol: String = System.lineSeparator()
6 |
--------------------------------------------------------------------------------
/WarmUp/Loops/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: edu
2 | custom_name: Mastermind - Play Game Function
3 | files:
4 | - name: src/main/kotlin/jetbrains/kotlin/course/warmup/Main.kt
5 | visible: true
6 | - name: src/main/kotlin/jetbrains/kotlin/course/warmup/Util.kt
7 | visible: false
8 | - name: test/Tests.kt
9 | visible: false
10 | - name: test/Methods.kt
11 | visible: false
12 | - name: test/MainClass.kt
13 | visible: false
14 | feedback_link: https://docs.google.com/forms/d/e/1FAIpQLScylICclQIi9_YDjO7iuyRITDLn0Qgzw_aLxKxiishKAbL0qg/viewform?usp=pp_url&entry.2103429047=Introduction/Warm+up/Loops
15 |
--------------------------------------------------------------------------------
/WarmUp/Loops/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 1441227087
2 |
--------------------------------------------------------------------------------
/WarmUp/Loops/test/MainClass.kt:
--------------------------------------------------------------------------------
1 | import org.jetbrains.academy.test.system.core.models.classes.TestClass
2 |
3 | internal val mainClass = TestClass(
4 | classPackage = "jetbrains.kotlin.course.warmup",
5 | customMethods = listOf(
6 | isCompleteMethod,
7 | generateSecretMethod,
8 | playGameMethod,
9 | getGameRulesMethod,
10 | countPartialMatchesMethod,
11 | countExactMatchesMethod,
12 | ),
13 | )
14 |
--------------------------------------------------------------------------------
/WarmUp/TypesOfVariables/src/main/kotlin/jetbrains/kotlin/course/warmup/Util.kt:
--------------------------------------------------------------------------------
1 | package jetbrains.kotlin.course.warmup
2 |
3 | fun safeReadLine() = readlnOrNull() ?: error("Your input is incorrect, sorry")
4 |
5 | val newLineSymbol: String = System.lineSeparator()
6 |
--------------------------------------------------------------------------------
/WarmUp/TypesOfVariables/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: edu
2 | custom_name: Mastermind - Variables for Game Settings
3 | files:
4 | - name: src/main/kotlin/jetbrains/kotlin/course/warmup/Main.kt
5 | visible: true
6 | - name: test/Tests.kt
7 | visible: false
8 | - name: src/main/kotlin/jetbrains/kotlin/course/warmup/Util.kt
9 | visible: false
10 | - name: test/Methods.kt
11 | visible: false
12 | - name: test/MainClass.kt
13 | visible: false
14 | feedback_link: https://docs.google.com/forms/d/e/1FAIpQLScylICclQIi9_YDjO7iuyRITDLn0Qgzw_aLxKxiishKAbL0qg/viewform?usp=pp_url&entry.2103429047=Introduction/Warm+up/Types+of+variables
15 |
--------------------------------------------------------------------------------
/WarmUp/TypesOfVariables/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 436171823
2 |
--------------------------------------------------------------------------------
/WarmUp/TypesOfVariables/test/MainClass.kt:
--------------------------------------------------------------------------------
1 | import org.jetbrains.academy.test.system.core.models.classes.TestClass
2 |
3 | internal val mainClass = TestClass(
4 | classPackage = "jetbrains.kotlin.course.warmup",
5 | customMethods = listOf(
6 | getGameRulesMethod,
7 | ),
8 | )
9 |
--------------------------------------------------------------------------------
/WarmUp/TypesOfVariables/test/Methods.kt:
--------------------------------------------------------------------------------
1 | import org.jetbrains.academy.test.system.core.models.TestKotlinType
2 | import org.jetbrains.academy.test.system.core.models.method.TestMethod
3 | import org.jetbrains.academy.test.system.core.models.variable.TestVariable
4 |
5 | internal val getGameRulesMethod = TestMethod(
6 | "getGameRules",
7 | TestKotlinType("String"),
8 | listOf(
9 | TestVariable("wordLength", "Int"),
10 | TestVariable("maxAttemptsCount", "Int"),
11 | TestVariable("secretExample", "String"),
12 | ),
13 | )
14 |
--------------------------------------------------------------------------------
/WarmUp/breakExpression/src/main/kotlin/jetbrains/kotlin/course/warmup/Util.kt:
--------------------------------------------------------------------------------
1 | package jetbrains.kotlin.course.warmup
2 |
3 | fun safeReadLine() = readlnOrNull() ?: error("Your input is incorrect, sorry")
4 |
5 | val newLineSymbol: String = System.lineSeparator()
6 |
--------------------------------------------------------------------------------
/WarmUp/breakExpression/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: theory
2 | custom_name: Mastermind - Break Expression
3 | files:
4 | - name: src/main/kotlin/jetbrains/kotlin/course/warmup/Util.kt
5 | visible: false
6 | - name: src/main/kotlin/jetbrains/kotlin/course/warmup/Main.kt
7 | visible: true
8 |
--------------------------------------------------------------------------------
/WarmUp/breakExpression/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 1972483715
2 |
--------------------------------------------------------------------------------
/WarmUp/breakExpression/task.md:
--------------------------------------------------------------------------------
1 | If you are working with a loop (whether `for` or `while`),
2 | you can stop it earlier with a special [`break`](https://kotlinlang.org/docs/returns.html) expression:
3 | ```kotlin
4 | while (x > 0) {
5 | // to do something
6 | if (x == 10) {
7 | break // break the loop
8 | }
9 | }
10 | ```
11 |
--------------------------------------------------------------------------------
/WarmUp/compositeIf/src/main/kotlin/jetbrains/kotlin/course/warmup/Util.kt:
--------------------------------------------------------------------------------
1 | package jetbrains.kotlin.course.warmup
2 |
3 | fun safeReadLine() = readlnOrNull() ?: error("Your input is incorrect, sorry")
4 |
5 | val newLineSymbol: String = System.lineSeparator()
6 |
--------------------------------------------------------------------------------
/WarmUp/compositeIf/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: theory
2 | custom_name: Mastermind - Boolean Operators
3 | files:
4 | - name: src/main/kotlin/jetbrains/kotlin/course/warmup/Util.kt
5 | visible: false
6 | - name: src/main/kotlin/jetbrains/kotlin/course/warmup/Main.kt
7 | visible: true
8 |
--------------------------------------------------------------------------------
/WarmUp/compositeIf/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 540878076
2 |
--------------------------------------------------------------------------------
/WarmUp/compositeIf/task.md:
--------------------------------------------------------------------------------
1 | For complex conditions in `if` expressions,
2 | special [built-in operators](https://kotlinlang.org/docs/booleans.html) `||` or `&&` can be used:
3 | `||` is true if _at least one_ condition is true;
4 | `&&` is true if _all_ the conditions are true:
5 | ```kotlin
6 | // Will be true if x > 5 OR y > 5, e.g., x = 3, y = 6 (true) or x = 6, y = 6 (true)
7 | if (x > 5 || y > 5) {
8 | TODO("Not implemented yet")
9 | }
10 | ```
11 | ```kotlin
12 | // Will be true if x > 5 AND y > 5, e.g., for x = 3, y = 6 (false) or x = 6, y = 6 (true)
13 | if (x > 5 && y > 5) {
14 | TODO("Not implemented yet")
15 | }
16 | ```
17 |
18 |
--------------------------------------------------------------------------------
/WarmUp/compositeOperators/src/main/kotlin/jetbrains/kotlin/course/warmup/Util.kt:
--------------------------------------------------------------------------------
1 | package jetbrains.kotlin.course.warmup
2 |
3 | fun safeReadLine() = readlnOrNull() ?: error("Your input is incorrect, sorry")
4 |
5 | val newLineSymbol: String = System.lineSeparator()
6 |
--------------------------------------------------------------------------------
/WarmUp/compositeOperators/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: theory
2 | custom_name: Mastermind - Composite If Operators
3 | files:
4 | - name: src/main/kotlin/jetbrains/kotlin/course/warmup/Util.kt
5 | visible: false
6 | - name: src/main/kotlin/jetbrains/kotlin/course/warmup/Main.kt
7 | visible: true
8 |
--------------------------------------------------------------------------------
/WarmUp/compositeOperators/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 1019379491
2 |
--------------------------------------------------------------------------------
/WarmUp/compositeOperators/task.md:
--------------------------------------------------------------------------------
1 | An `if` expression can have more than two `if..else` branches: there may also be some intermediate ones:
2 | ```kotlin
3 | if (x > 0) {
4 | TODO("Not implemented yet")
5 | } else if (x == 0) {
6 | TODO("Not implemented yet")
7 | }
8 | ```
9 | Another example:
10 | ```kotlin
11 | if (x > 0) {
12 | TODO("Not implemented yet")
13 | } else if (x == 0) {
14 | TODO("Not implemented yet")
15 | } else if (x < 0 && x != 5) {
16 | TODO("Not implemented yet")
17 | } else {
18 | TODO("Not implemented yet")
19 | }
20 | ```
21 |
--------------------------------------------------------------------------------
/WarmUp/countPartialMatches/src/main/kotlin/jetbrains/kotlin/course/warmup/Util.kt:
--------------------------------------------------------------------------------
1 | package jetbrains.kotlin.course.warmup
2 |
3 | fun safeReadLine() = readlnOrNull() ?: error("Your input is incorrect, sorry")
4 |
5 | val newLineSymbol: String = System.lineSeparator()
6 |
--------------------------------------------------------------------------------
/WarmUp/countPartialMatches/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: edu
2 | custom_name: Mastermind - countPartialMatches Function
3 | files:
4 | - name: src/main/kotlin/jetbrains/kotlin/course/warmup/Util.kt
5 | visible: false
6 | - name: src/main/kotlin/jetbrains/kotlin/course/warmup/Main.kt
7 | visible: true
8 | - name: test/MainClass.kt
9 | visible: false
10 | - name: test/Methods.kt
11 | visible: false
12 | - name: test/Tests.kt
13 | visible: false
14 |
--------------------------------------------------------------------------------
/WarmUp/countPartialMatches/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 215738047
2 |
--------------------------------------------------------------------------------
/WarmUp/countPartialMatches/test/MainClass.kt:
--------------------------------------------------------------------------------
1 | import org.jetbrains.academy.test.system.core.models.classes.TestClass
2 |
3 | internal val mainClass = TestClass(
4 | classPackage = "jetbrains.kotlin.course.warmup",
5 | customMethods = listOf(
6 | isCompleteMethod,
7 | countExactMatchesMethod,
8 | countPartialMatchesMethod,
9 | generateSecretMethod,
10 | getGameRulesMethod,
11 | countAllMatches,
12 | playGameMethod
13 | ),
14 | )
15 |
--------------------------------------------------------------------------------
/WarmUp/customFunctionsTheory/src/main/kotlin/jetbrains/kotlin/course/warmup/Util.kt:
--------------------------------------------------------------------------------
1 | package jetbrains.kotlin.course.warmup
2 |
3 | fun safeReadLine() = readlnOrNull() ?: error("Your input is incorrect, sorry")
4 |
5 | val newLineSymbol: String = System.lineSeparator()
6 |
--------------------------------------------------------------------------------
/WarmUp/customFunctionsTheory/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: theory
2 | custom_name: Mastermind - Custom Functions
3 | files:
4 | - name: src/main/kotlin/jetbrains/kotlin/course/warmup/Main.kt
5 | visible: true
6 | - name: src/main/kotlin/jetbrains/kotlin/course/warmup/Util.kt
7 | visible: false
8 |
--------------------------------------------------------------------------------
/WarmUp/customFunctionsTheory/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 1006365197
2 |
--------------------------------------------------------------------------------
/WarmUp/customFunctionsTheoryPartTwo/src/main/kotlin/jetbrains/kotlin/course/warmup/Util.kt:
--------------------------------------------------------------------------------
1 | package jetbrains.kotlin.course.warmup
2 |
3 | fun safeReadLine() = readlnOrNull() ?: error("Your input is incorrect, sorry")
4 |
5 | val newLineSymbol: String = System.lineSeparator()
6 |
--------------------------------------------------------------------------------
/WarmUp/customFunctionsTheoryPartTwo/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: theory
2 | custom_name: Mastermind - Functions as Expressions
3 | files:
4 | - name: src/main/kotlin/jetbrains/kotlin/course/warmup/Main.kt
5 | visible: true
6 | - name: src/main/kotlin/jetbrains/kotlin/course/warmup/Util.kt
7 | visible: false
8 |
--------------------------------------------------------------------------------
/WarmUp/customFunctionsTheoryPartTwo/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 964908412
2 |
--------------------------------------------------------------------------------
/WarmUp/customFunctionsTheoryPartTwo/task.md:
--------------------------------------------------------------------------------
1 | If a function can be expressed in [one statement](https://kotlinlang.org/docs/idioms.html#single-expression-functions) (one action in the code),
2 | the `return` keyword, the type of the return value, and curly braces can be omitted. For example, consider the following code:
3 | ```kotlin
4 | fun myName(intVariable: Int): Int {
5 | return intVariable + 5
6 | }
7 | ```
8 | It is equivalent to:
9 | ```kotlin
10 | fun myName(intVariable: Int) = intVariable + 5
11 | ```
12 |
13 | These functions usually help to make code shorter and write code in more Kotlin-like style.
14 |
--------------------------------------------------------------------------------
/WarmUp/ifDefinition/src/main/kotlin/jetbrains/kotlin/course/warmup/Util.kt:
--------------------------------------------------------------------------------
1 | package jetbrains.kotlin.course.warmup
2 |
3 | fun safeReadLine() = readlnOrNull() ?: error("Your input is incorrect, sorry")
4 |
5 | val newLineSymbol: String = System.lineSeparator()
6 |
--------------------------------------------------------------------------------
/WarmUp/ifDefinition/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: theory
2 | custom_name: Mastermind - Conditional Operator
3 | files:
4 | - name: src/main/kotlin/jetbrains/kotlin/course/warmup/Main.kt
5 | visible: true
6 | - name: src/main/kotlin/jetbrains/kotlin/course/warmup/Util.kt
7 | visible: false
8 |
--------------------------------------------------------------------------------
/WarmUp/ifDefinition/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 990585351
2 |
--------------------------------------------------------------------------------
/WarmUp/ifDefinition/task.md:
--------------------------------------------------------------------------------
1 | The conditional operator (the [`if`](https://kotlinlang.org/docs/control-flow.html#if-expression) expression)
2 | is used when the program has some choice.
3 | For example, if the variable contains a positive number, display it on the screen,
4 | otherwise do nothing.
5 | Or, if the guess matches the secret, end the game.
6 |
7 | Consider the following example:
8 | ```kotlin
9 | if (y > 0) {
10 | println(y)
11 | }
12 | ```
13 | Another example:
14 | ```kotlin
15 | if (x > y) {
16 | println(x)
17 | } else {
18 | // The opposite condition: x <= y
19 | println(y)
20 | }
21 | ```
22 |
23 | For the `else` branch, the reverse of the original condition is used: for example,
24 | for `x > y`, the opposite condition is `x <= y`.
25 |
--------------------------------------------------------------------------------
/WarmUp/ifExpression/src/main/kotlin/jetbrains/kotlin/course/warmup/Util.kt:
--------------------------------------------------------------------------------
1 | package jetbrains.kotlin.course.warmup
2 |
3 | fun safeReadLine() = readlnOrNull() ?: error("Your input is incorrect, sorry")
4 |
5 | val newLineSymbol: String = System.lineSeparator()
6 |
--------------------------------------------------------------------------------
/WarmUp/ifExpression/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: theory
2 | custom_name: Mastermind - Conditional Operator as Expression
3 | files:
4 | - name: src/main/kotlin/jetbrains/kotlin/course/warmup/Main.kt
5 | visible: true
6 | - name: src/main/kotlin/jetbrains/kotlin/course/warmup/Util.kt
7 | visible: false
8 |
--------------------------------------------------------------------------------
/WarmUp/ifExpression/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 1691431341
2 |
--------------------------------------------------------------------------------
/WarmUp/isCompleteFunction/src/main/kotlin/jetbrains/kotlin/course/warmup/Util.kt:
--------------------------------------------------------------------------------
1 | package jetbrains.kotlin.course.warmup
2 |
3 | fun safeReadLine() = readlnOrNull() ?: error("Your input is incorrect, sorry")
4 |
5 | val newLineSymbol: String = System.lineSeparator()
6 |
--------------------------------------------------------------------------------
/WarmUp/isCompleteFunction/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: edu
2 | custom_name: Mastermind - isComplete Function
3 | files:
4 | - name: src/main/kotlin/jetbrains/kotlin/course/warmup/Main.kt
5 | visible: true
6 | - name: src/main/kotlin/jetbrains/kotlin/course/warmup/Util.kt
7 | visible: false
8 | - name: test/Tests.kt
9 | visible: false
10 | - name: test/MainClass.kt
11 | visible: false
12 | - name: test/Methods.kt
13 | visible: false
14 |
--------------------------------------------------------------------------------
/WarmUp/isCompleteFunction/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 1170272381
2 |
--------------------------------------------------------------------------------
/WarmUp/isCompleteFunction/task.md:
--------------------------------------------------------------------------------
1 | In this task we will create a function to check if the game is complete.
2 |
3 | ### Task
4 |
5 | - Define a function `isComplete`, which accepts `secret` and `guess` and checks if the game is over.
6 | For now, let it always return `true`. We will implement the function logic later.
7 |
8 |
9 |
10 | The signature of the function is:
11 | ```kotlin
12 | fun isComplete(secret: String, guess: String): Boolean
13 | ```
14 |
15 |
--------------------------------------------------------------------------------
/WarmUp/isCompleteFunction/test/MainClass.kt:
--------------------------------------------------------------------------------
1 | import org.jetbrains.academy.test.system.core.models.classes.TestClass
2 |
3 | internal val mainClass = TestClass(
4 | classPackage = "jetbrains.kotlin.course.warmup",
5 | customMethods = listOf(
6 | getGameRulesMethod,
7 | generateSecretMethod,
8 | countPartialMatchesMethod,
9 | countExactMatchesMethod,
10 | isCompleteMethod
11 | ),
12 | )
13 |
--------------------------------------------------------------------------------
/WarmUp/isLostFunction/src/main/kotlin/jetbrains/kotlin/course/warmup/Util.kt:
--------------------------------------------------------------------------------
1 | package jetbrains.kotlin.course.warmup
2 |
3 | fun safeReadLine() = readlnOrNull() ?: error("Your input is incorrect, sorry")
4 |
5 | val newLineSymbol: String = System.lineSeparator()
6 |
--------------------------------------------------------------------------------
/WarmUp/isLostFunction/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: edu
2 | custom_name: Mastermind - isLost Function
3 | files:
4 | - name: src/main/kotlin/jetbrains/kotlin/course/warmup/Util.kt
5 | visible: false
6 | - name: src/main/kotlin/jetbrains/kotlin/course/warmup/Main.kt
7 | visible: true
8 | - name: test/MainClass.kt
9 | visible: false
10 | - name: test/Methods.kt
11 | visible: false
12 | - name: test/Tests.kt
13 | visible: false
14 |
--------------------------------------------------------------------------------
/WarmUp/isLostFunction/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 168358096
2 |
--------------------------------------------------------------------------------
/WarmUp/isLostFunction/task.md:
--------------------------------------------------------------------------------
1 | Let's implement the second function.
2 |
3 | ### Task
4 |
5 | Add a function `isLost`, which accepts three arguments: `complete`, `attempts`, and `maxAttemptsCount`
6 | and returns `true` only if the user **did not** guess the word (the `complete` variable stores `false`) **and** spent _more_ than `maxAttemptsCount` attempts.
7 |
8 |
9 |
10 | The signature of the function is:
11 | ```kotlin
12 | fun isLost(complete: Boolean, attempts: Int, maxAttemptsCount: Int): Boolean
13 | ```
14 |
15 |
--------------------------------------------------------------------------------
/WarmUp/isLostFunction/test/MainClass.kt:
--------------------------------------------------------------------------------
1 | import org.jetbrains.academy.test.system.core.models.classes.TestClass
2 |
3 | internal val mainClass = TestClass(
4 | classPackage = "jetbrains.kotlin.course.warmup",
5 | customMethods = listOf(
6 | isCompleteMethod,
7 | countExactMatchesMethod,
8 | countPartialMatchesMethod,
9 | generateSecretMethod,
10 | getGameRulesMethod,
11 | countAllMatches,
12 | printRoundResultsMethod,
13 | isWinMethod,
14 | isLostMethod,
15 | playGameMethod
16 | ),
17 | )
18 |
--------------------------------------------------------------------------------
/WarmUp/isWinFunction/src/main/kotlin/jetbrains/kotlin/course/warmup/Util.kt:
--------------------------------------------------------------------------------
1 | package jetbrains.kotlin.course.warmup
2 |
3 | fun safeReadLine() = readlnOrNull() ?: error("Your input is incorrect, sorry")
4 |
5 | val newLineSymbol: String = System.lineSeparator()
6 |
--------------------------------------------------------------------------------
/WarmUp/isWinFunction/task-info.yaml:
--------------------------------------------------------------------------------
1 | type: edu
2 | custom_name: Mastermind - isWon Function
3 | files:
4 | - name: src/main/kotlin/jetbrains/kotlin/course/warmup/Util.kt
5 | visible: false
6 | - name: src/main/kotlin/jetbrains/kotlin/course/warmup/Main.kt
7 | visible: true
8 | - name: test/MainClass.kt
9 | visible: false
10 | - name: test/Methods.kt
11 | visible: false
12 | - name: test/Tests.kt
13 | visible: false
14 |
--------------------------------------------------------------------------------
/WarmUp/isWinFunction/task-remote-info.yaml:
--------------------------------------------------------------------------------
1 | id: 1496648535
2 |
--------------------------------------------------------------------------------
/WarmUp/isWinFunction/task.md:
--------------------------------------------------------------------------------
1 | It's time to implement functions that indicate if the user win or lose. Let's start from the first one.
2 |
3 | ### Task
4 |
5 | Add a function `isWon`, which accepts three arguments: `complete`, `attempts`, and `maxAttemptsCount`
6 | and returns `true` only if the user guessed the word (the `complete` variable stores `true`)
7 | **and** spent _not more_ than `maxAttemptsCount` attempts.
8 |
9 |
10 |
11 | The signature of the function is:
12 | ```kotlin
13 | fun isWon(complete: Boolean, attempts: Int, maxAttemptsCount: Int): Boolean
14 | ```
15 |