Skip to content

Commit 8fecf07

Browse files
committed
Added missing space after // in example sluglines
This exposed numerous other code files.
1 parent 33e11d2 commit 8fecf07

File tree

36 files changed

+613
-21
lines changed

36 files changed

+613
-21
lines changed

Examples/Booleans/Foo.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Booleans/Foo.kt
2+
// (c)2020 Mindview LLC. See Copyright.txt for permissions.
3+
package booleansExercise4
4+
5+
fun foo(): Boolean = true

Examples/Booleans/Task4.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Booleans/Task4.kt
2+
// (c)2020 Mindview LLC. See Copyright.txt for permissions.
3+
package booleansExercise4
4+
5+
fun main() {
6+
println(foo())
7+
}

Examples/Constructors/Task4.kt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Constructors/Task4.kt
2+
// (c)2020 Mindview LLC. See Copyright.txt for permissions.
3+
package constructorsExercise4
4+
5+
class Human(
6+
val name: String,
7+
val age: Int
8+
) {
9+
override fun toString(): String {
10+
return "Human(name='$name', age=$age)"
11+
}
12+
}
13+
14+
fun main() {
15+
val human = Human("Rick", 70)
16+
println(human)
17+
}
18+
/* Output:
19+
Human(name='Rick', age=70)
20+
*/

Examples/CreatingClasses/Task4.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// CreatingClasses/Task4.kt
2+
// (c)2020 Mindview LLC. See Copyright.txt for permissions.
3+
package creatingClassesExercise4
4+
5+
fun main() {
6+
val s: String = "Hello!"
7+
println(s.toUpperCase())
8+
println(s.toLowerCase())
9+
}
10+
/* Output:
11+
HELLO!
12+
hello!
13+
*/

Examples/CreatingClasses/Task5.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// CreatingClasses/Task5.kt
2+
// (c)2020 Mindview LLC. See Copyright.txt for permissions.
3+
package creatingClassesExercise5
4+
5+
fun cap(s: String) = s.capitalize()
6+
7+
fun main() {
8+
println(cap("hi!"))
9+
println(cap("Hi!"))
10+
}
11+
/* Output:
12+
Hi!
13+
Hi!
14+
*/

Examples/DataTypes/Task4.kt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// DataTypes/Task4.kt
2+
// (c)2020 Mindview LLC. See Copyright.txt for permissions.
3+
package dataTypesExercise4
4+
5+
fun main() {
6+
val whole = 11
7+
val fractional = 1.4
8+
val trueOrFalse = true
9+
val words = "A value"
10+
val character = 'z'
11+
val lines = """Triple quotes let
12+
you have many lines
13+
in your string"""
14+
println(whole)
15+
println(fractional)
16+
println(trueOrFalse)
17+
println(words)
18+
println(character)
19+
println(lines)
20+
}
21+
/* Output:
22+
11
23+
1.4
24+
true
25+
A value
26+
z
27+
Triple quotes let
28+
you have many lines
29+
in your string
30+
*/

Examples/DataTypes/Task5.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// DataTypes/Task5.kt
2+
// (c)2020 Mindview LLC. See Copyright.txt for permissions.
3+
package dataTypesExercise5
4+
5+
fun main() {
6+
val s = "Sally" + 5.9
7+
println(s)
8+
}

Examples/Exceptions/Task4.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Exceptions/Task4.kt
2+
// (c)2020 Mindview LLC. See Copyright.txt for permissions.
3+
package exceptionsExercise4
4+
5+
fun foo() {
6+
throw IllegalStateException("something is wrong")
7+
}
8+
9+
fun bar() {
10+
foo()
11+
}
12+
13+
fun main() {
14+
// bar() // Uncomment this to see exception
15+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// ExpressionsStatements/Task4.kt
2+
// (c)2020 Mindview LLC. See Copyright.txt for permissions.
3+
package expressionsAndStatementsExercise4
4+
5+
fun main() {
6+
var x = 1
7+
x = 2
8+
println(x)
9+
}

Examples/ExtensionFunctions/Task4.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// ExtensionFunctions/Task4.kt
2+
// (c)2020 Mindview LLC. See Copyright.txt for permissions.
3+
package extensionFunctionsExercise4
4+
import atomictest.eq
5+
6+
class Book(val title: String)
7+
8+
fun Book.categorize(category: String) =
9+
"""title: "$title", category: $category"""
10+
11+
fun main() {
12+
Book("Dracula").categorize("Vampire") eq
13+
"""title: "Dracula", category: Vampire"""
14+
}

Examples/Functions/Task4.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Functions/Task4.kt
2+
// (c)2020 Mindview LLC. See Copyright.txt for permissions.
3+
package functionsExercise4
4+
5+
fun foo(): String {
6+
return "abc"
7+
}
8+
9+
fun main() {
10+
println(foo())
11+
}

Examples/HelloWorld/Task4.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// HelloWorld/Task4.kt
2+
// (c)2020 Mindview LLC. See Copyright.txt for permissions.
3+
package helloWorldExercise4
4+
5+
fun main() {
6+
println("Hello, Kotlin!")
7+
}

Examples/HelloWorld/Task5.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// HelloWorld/Task5.kt
2+
// (c)2020 Mindview LLC. See Copyright.txt for permissions.
3+
package helloWorldExercise5
4+
5+
fun main() {
6+
println("Hello, Kotlin!")
7+
}

Examples/IfExpressions/Task4.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// IfExpressions/Task4.kt
2+
// (c)2020 Mindview LLC. See Copyright.txt for permissions.
3+
package ifExpressionsExercise4
4+
5+
fun oneOrTheOther(exp: Boolean) =
6+
if (exp)
7+
"True!"
8+
else
9+
"False"
10+
11+
fun main() {
12+
val x = 1
13+
println(oneOrTheOther(x == 1)) // True!
14+
}

Examples/InKeyword/Task5.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// InKeyword/Task5.kt
2+
// (c)2020 Mindview LLC. See Copyright.txt for permissions.
3+
package theInKeywordExercise5
4+
5+
fun foo() {
6+
println("foo")
7+
}

Examples/Lists/Task4.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Lists/Task4.kt
2+
// (c)2020 Mindview LLC. See Copyright.txt for permissions.
3+
package listsExercise4
4+
5+
fun main() {
6+
val list = listOf('a', 'b', 'c', 'd', 'e').subList(1, 3)
7+
println(list)
8+
}

Examples/LoopingAndRanges/Task5.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// LoopingAndRanges/Task5.kt
2+
// (c)2020 Mindview LLC. See Copyright.txt for permissions.
3+
package loopingAndRangesExercise5
4+
5+
fun main() {
6+
val s = "abcd"
7+
8+
}

Examples/Maps/Task4.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Maps/Task4.kt
2+
// (c)2020 Mindview LLC. See Copyright.txt for permissions.
3+
package mapsExercise4
4+
5+
fun main() {
6+
val map = mapOf(
7+
1 to "one",
8+
2 to "two",
9+
3 to "three",
10+
)
11+
println(map)
12+
}

Examples/NamedAndDefaultArgs/Task4.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// NamedAndDefaultArgs/Task4.kt
2+
// (c)2020 Mindview LLC. See Copyright.txt for permissions.
3+
package namedAndDefaultArgumentsExercise4
4+
import atomictest.eq
5+
6+
fun foo(i: Int, s: String) = "(i = $i, s = $s)"
7+
8+
fun bar(i: Int, s: String) = "(i = $i, s = $s)"
9+
10+
fun main() {
11+
foo(i = 1, s = "abc") eq "(i = 1, s = abc)"
12+
foo(2, "def") eq "(i = 2, s = def)"
13+
14+
bar(i = 1, s = "abc") eq "(i = 1, s = abc)"
15+
bar(2, "def") eq "(i = 2, s = def)"
16+
}

Examples/NumberTypes/Task5.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// NumberTypes/Task5.kt
2+
// (c)2020 Mindview LLC. See Copyright.txt for permissions.
3+
package numberTypesExercise5
4+
5+
fun main() {
6+
val x = 10
7+
println(x + 1)
8+
}

Examples/ObjectsEverywhere/Task5.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// ObjectsEverywhere/Task5.kt
2+
// (c)2020 Mindview LLC. See Copyright.txt for permissions.
3+
package objectsEverywhereExercise5
4+
5+
fun main() {
6+
val r = IntRange(0, 10)
7+
8+
val s = "abc"
9+
10+
}

Examples/Overloading/Task4.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Overloading/Task4.kt
2+
// (c)2020 Mindview LLC. See Copyright.txt for permissions.
3+
package overloadingExercise4
4+
import atomictest.eq
5+
6+
fun f(n: Int = 0) = n + 373
7+
8+
fun main() {
9+
f() eq 373
10+
}

Examples/Properties/Task4.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Properties/Task4.kt
2+
// (c)2020 Mindview LLC. See Copyright.txt for permissions.
3+
package propertiesExercise4
4+
5+
class Counter {
6+
var value = 0
7+
8+
fun inc() {
9+
value += 10
10+
}
11+
12+
fun dec() {
13+
value -= 10
14+
}
15+
}

Examples/PropertyAccessors/Task5.kt

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// PropertyAccessors/Task5.kt
2+
// (c)2020 Mindview LLC. See Copyright.txt for permissions.
3+
package propertyAccessorsExercise5
4+
import atomictest.eq
5+
6+
class Hamster(val name: String)
7+
8+
class Cage(private val maxCapacity: Int) {
9+
private val hamsters =
10+
mutableListOf<Hamster>()
11+
12+
val capacity: Int
13+
get() = maxCapacity - hamsters.size
14+
15+
val full: Boolean
16+
get() = hamsters.size == maxCapacity
17+
18+
fun put(hamster: Hamster): Boolean =
19+
if (full)
20+
false
21+
else {
22+
hamsters += hamster
23+
true
24+
}
25+
26+
fun takeHamster(): Hamster =
27+
hamsters.removeAt(0)
28+
}
29+
30+
fun main() {
31+
val cage = Cage(maxCapacity = 2)
32+
cage.full eq false
33+
cage.capacity eq 2
34+
cage.put(Hamster("Alice")) eq true
35+
cage.put(Hamster("Bob")) eq true
36+
cage.full eq true
37+
cage.capacity eq 0
38+
cage.put(Hamster("Charlie")) eq false
39+
cage.takeHamster()
40+
cage.capacity eq 1
41+
}

Examples/RepetitionWithWhile/Task4.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// RepetitionWithWhile/Task4.kt
2+
// (c)2020 Mindview LLC. See Copyright.txt for permissions.
3+
package repetitionWithWhileExercise4
4+
5+
fun getFooResult(): Int = 736
6+
7+
fun main() {
8+
println("Foo result is: ${getFooResult()}")
9+
}

Examples/RepetitionWithWhile/Task5.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// RepetitionWithWhile/Task5.kt
2+
// (c)2020 Mindview LLC. See Copyright.txt for permissions.
3+
package repetitionWithWhileExercise5
4+
5+
fun getFooResult(): Int = 736
6+
7+
fun main() {
8+
println("Foo result is: ${getFooResult()}")
9+
}

Examples/Sets/Task4.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Sets/Task4.kt
2+
// (c)2020 Mindview LLC. See Copyright.txt for permissions.
3+
package setsExercise4
4+
5+
fun main() {
6+
val list = listOf(1, 2, 3, 4)
7+
println(list)
8+
}

Examples/StringTemplates/Task4.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// StringTemplates/Task4.kt
2+
// (c)2020 Mindview LLC. See Copyright.txt for permissions.
3+
package stringTemplatesExercise4
4+
5+
// foo
6+
fun foo() = 1
7+
8+
fun main() {
9+
println(foo())
10+
}

Examples/StringTemplates/Task5.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// StringTemplates/Task5.kt
2+
// (c)2020 Mindview LLC. See Copyright.txt for permissions.
3+
package stringTemplatesExercise5
4+
5+
fun main() {
6+
val answer = 42
7+
println("The answer is $answer")
8+
}

Examples/Testing/Task4.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Testing/Task4.kt
2+
// (c)2020 Mindview LLC. See Copyright.txt for permissions.
3+
package testingExercise4
4+
5+
fun main() {
6+
// println("Uncomment me")
7+
println("Comment me")
8+
}

0 commit comments

Comments
 (0)