1
1
Fork 0

Updated examples based on the latest changes in the book

This commit is contained in:
Svetlana Isakova 2021-07-21 22:45:01 +02:00
parent 24d983c6ec
commit a45abd2896
8 changed files with 11 additions and 11 deletions

View File

@ -8,7 +8,7 @@ fun main() {
val alien1 =
MutableNameAlien("Reverse Giraffe")
val alien2 =
FixedNameAlien("Krombopolis Michael")
FixedNameAlien("Krombopulos Michael")
alien1.name = "Parasite"
// Can't do this:

View File

@ -10,10 +10,10 @@ fun main() {
v2 eq "Ontology"
// 'neq' means "not equal"
v2 neq "Epistimology"
v2 neq "Epistemology"
// [Error] Epistimology != Ontology
// v2 eq "Epistimology"
// [Error] Epistemology != Ontology
// v2 eq "Epistemology"
}
/* Output:
11

View File

@ -4,7 +4,7 @@ fun isClosed(hour: Int) {
val open = 9
val closed = 20
println("Operating hours: $open - $closed")
val status = hour < open || hour > closed
val status = hour < open || hour >= closed
println("Closed: $status")
}

View File

@ -5,7 +5,7 @@ fun isOpen1(hour: Int) {
val closed = 20
println("Operating hours: $open - $closed")
val status =
if (hour >= open && hour <= closed) // [1]
if (hour >= open && hour < closed) // [1]
true
else
false

View File

@ -4,7 +4,7 @@ fun isOpen2(hour: Int) {
val open = 9
val closed = 20
println("Operating hours: $open - $closed")
val status = hour >= open && hour <= closed
val status = hour >= open && hour < closed
println("Open: $status")
}

View File

@ -7,11 +7,11 @@ fun main() {
val hour = 6
println("Current time: " + hour)
val isOpen = hour >= opens && hour <= closes
val isOpen = hour >= opens && hour < closes
println("Open: " + isOpen)
println("Not open: " + !isOpen)
val isClosed = hour < opens || hour > closes
val isClosed = hour < opens || hour >= closes
println("Closed: " + isClosed)
}
/* Output:

View File

@ -11,7 +11,7 @@ fun main() {
val closes = 20
println("Operating hours: " +
opens + " - " + closes)
hour >= opens && hour <= closes
hour >= opens && hour < closes
} else {
false
}

View File

@ -14,7 +14,7 @@ fun main() {
"Miffy",
"Miller",
"1-234-567890",
"1600 Amphitheatre Parkway")
"1600 Amphitheater Parkway")
val newContact = contact.copy(
number = "098-765-4321",
address = "Brandschenkestrasse 110")