diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..e96534f --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/1_hello_world.kt b/src/1_hello_world.kt similarity index 72% rename from 1_hello_world.kt rename to src/1_hello_world.kt index 7b6f0b5..eb8ffac 100644 --- a/1_hello_world.kt +++ b/src/1_hello_world.kt @@ -1,4 +1,6 @@ +// Hello World App + fun main(args: Array) { print("Hello World") -} \ No newline at end of file +} diff --git a/src/2_explore_first_app.kt b/src/2_explore_first_app.kt new file mode 100644 index 0000000..b20e95c --- /dev/null +++ b/src/2_explore_first_app.kt @@ -0,0 +1,18 @@ + +// Explore First App + +fun main(args: Array) { + + println("Hello World") + + println(10) + + println(true) + + println(10 / 2) + + println(94.2f) + + println(9 - 3) + +} diff --git a/src/3_comments.kt b/src/3_comments.kt new file mode 100644 index 0000000..1f4551b --- /dev/null +++ b/src/3_comments.kt @@ -0,0 +1,14 @@ + + + +/* +* This is comment line 1 +* +* This is comment line 2 +* +* This is main function. Entry point of the application. +* */ + +fun main(args: Array) { // This is inline comment ... + print("Hello World") +} diff --git a/src/4_variables_data_types.kt b/src/4_variables_data_types.kt new file mode 100644 index 0000000..d694e9f --- /dev/null +++ b/src/4_variables_data_types.kt @@ -0,0 +1,19 @@ + +/* +* This is main function. Entry point of the application. +* */ +fun main(args: Array) { + + var myNumber = 10 // Int + var myDecimal = 1.0 // Float + var isActive = true // Boolean + + var myString: String // Mutable String + myString = "Hello World" + myString = "Another World" + + val myAnotherString = "My constant string value" // Immutable String +// myAnotherString = "some value" // NOT ALLOWED, since it is immutable + + print(myNumber) +} diff --git a/src/5_kotlin_basics.kt b/src/5_kotlin_basics.kt new file mode 100644 index 0000000..081ffbe --- /dev/null +++ b/src/5_kotlin_basics.kt @@ -0,0 +1,17 @@ + + +/* +* This is main function. Entry point of the application. +* */ +fun main(args: Array) { + + var personObj = Person() + personObj.name = "Steve" + + print("The name of the person is ${personObj.name}") +} + +class Person { + + var name: String = "" +} diff --git a/src/6_Person.kt b/src/6_Person.kt new file mode 100644 index 0000000..c02d702 --- /dev/null +++ b/src/6_Person.kt @@ -0,0 +1,7 @@ + +class Persson(var name: String ) { + + fun display() { + print("The name of the person is ${name}") + } +} diff --git a/src/6_kotlin_basics.kt b/src/6_kotlin_basics.kt new file mode 100644 index 0000000..3cbcd31 --- /dev/null +++ b/src/6_kotlin_basics.kt @@ -0,0 +1,10 @@ + +/* +* This is main function. Entry point of the application. +* */ +fun main(args: Array) { + + var personObj = Persson("Steve") + + personObj.display() +} diff --git a/src/7_data_types.kt b/src/7_data_types.kt new file mode 100644 index 0000000..bcf5bc2 --- /dev/null +++ b/src/7_data_types.kt @@ -0,0 +1,21 @@ + +/* +* Explore Data Types in Kotlin +* */ + +fun main(args: Array) { + + var name: String + name = "Kevin" + + var age: Int = 10 + var myAge = 10 + + var isAlive: Boolean = true + var marks: Float = 97.4F + var percentage: Double = 90.78 + var gender: Char = 'M' + + print(marks) +} + diff --git a/src/8_string_interpolation.kt b/src/8_string_interpolation.kt new file mode 100644 index 0000000..c09117b --- /dev/null +++ b/src/8_string_interpolation.kt @@ -0,0 +1,19 @@ + +/* +* Explore String Interpolation in Kotlin +* */ +fun main(args: Array) { + + var rect = Rectangle() + rect.length = 5 + rect.breadth = 3 + + print("The length of the rectangle is ${rect.length} and breadth is ${rect.breadth}. The area is ${rect.length * rect.breadth}") + +} + +class Rectangle { + + var length: Int = 0 + var breadth: Int = 0 +} \ No newline at end of file diff --git a/src/9_ranges.kt b/src/9_ranges.kt new file mode 100644 index 0000000..71821e6 --- /dev/null +++ b/src/9_ranges.kt @@ -0,0 +1,28 @@ + + +/* +* Explore Ranges +* */ +fun main(args: Array) { + + var r1 = 1..5 + // This range contains number 1, 2, 3, 4, 5 + + val r2 = 5 downTo 1 + // This range contains number 5, 4, 3, 2, 1 + + val r3 = 5 downTo 1 step 2 + // This range contains number 5, 3, 1 + + val r4 = 'a'..'z' + // This range contains the values from "a", "b", "c" . . . "z" + + var isPresent = 'c' in r4 + + var countDown = 10.downTo(1) + // This range contains number 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 + + var moveUp = 1.rangeTo(10) + // This range contains number 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 + +}