├── .gitignore ├── .idea ├── .gitignore ├── codeStyles │ ├── Project.xml │ └── codeStyleConfig.xml ├── kotlinc.xml ├── libraries │ └── KotlinJavaRuntime.xml ├── misc.xml └── modules.xml ├── kotlin-crash-course.iml └── src ├── Animal.kt ├── Cat.kt ├── Dog.kt └── Main.kt /.gitignore: -------------------------------------------------------------------------------- 1 | # Project exclude paths 2 | /out/ -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /workspace.xml -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 20 | 22 | 23 | 25 | 26 | -------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/kotlinc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /.idea/libraries/KotlinJavaRuntime.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /kotlin-crash-course.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/Animal.kt: -------------------------------------------------------------------------------- 1 | abstract class Animal( 2 | val name: String, 3 | val legCount: Int = 4 4 | ) { 5 | 6 | init { 7 | println("Hello, my name is $name") 8 | } 9 | 10 | abstract fun makeSound() 11 | } -------------------------------------------------------------------------------- /src/Cat.kt: -------------------------------------------------------------------------------- 1 | class Cat : Animal("Cat") { 2 | 3 | override fun makeSound() { 4 | println("MEOW!!!") 5 | } 6 | } -------------------------------------------------------------------------------- /src/Dog.kt: -------------------------------------------------------------------------------- 1 | 2 | 3 | class Dog : Animal("Dog") { 4 | 5 | override fun makeSound() { 6 | println("WUFF!!!") 7 | } 8 | } -------------------------------------------------------------------------------- /src/Main.kt: -------------------------------------------------------------------------------- 1 | 2 | 3 | fun main() { 4 | val list = listOf("Kotlin", "is", "fun") 5 | val count = list.customCount { currentString -> 6 | currentString.length >= 3 7 | } 8 | println(count) 9 | } 10 | 11 | fun List.customCount(function: (T) -> Boolean): Int { 12 | var counter = 0 13 | for(string in this) { 14 | if(function(string)) { 15 | counter++ 16 | } 17 | } 18 | return counter 19 | } 20 | 21 | fun Int.isOdd(): Boolean { 22 | return this % 2 == 1 23 | } 24 | 25 | fun isEven(number: Int = 10): Boolean { 26 | return number % 2 == 0 27 | } 28 | 29 | fun print10Numbers() { 30 | for(i in 1..10) { 31 | println(i) 32 | } 33 | } 34 | --------------------------------------------------------------------------------