Skip to content

Commit 99c2db6

Browse files
committed
chore: add prints to tour exercises
1 parent 6090485 commit 99c2db6

5 files changed

+63
-7
lines changed

docs/topics/tour/kotlin-tour-intermediate-classes-interfaces.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,12 +397,18 @@ fun main() {
397397
val bedroomThermostat = SmartThermostat("Bedroom Thermostat")
398398

399399
livingRoomLight.turnOn()
400+
// Living Room Light is now ON.
400401
livingRoomLight.adjustBrightness(10)
402+
// Adjusting Living Room Light brightness to 10%.
401403
livingRoomLight.turnOff()
404+
// Living Room Light is now OFF.
402405

403406
bedroomThermostat.turnOn()
407+
// Bedroom Thermostat thermostat is now heating.
404408
bedroomThermostat.adjustTemperature(5)
409+
// Bedroom Thermostat thermostat set to 5°C.
405410
bedroomThermostat.turnOff()
411+
// Bedroom Thermostat thermostat is now off.
406412
}
407413
```
408414
{validate="false" kotlin-runnable="true" kotlin-min-compiler-version="1.3" id="kotlin-tour-classes-interfaces-exercise-1"}
@@ -448,12 +454,18 @@ fun main() {
448454
val bedroomThermostat = SmartThermostat("Bedroom Thermostat")
449455

450456
livingRoomLight.turnOn()
457+
// Living Room Light is now ON.
451458
livingRoomLight.adjustBrightness(10)
459+
// Adjusting Living Room Light brightness to 10%.
452460
livingRoomLight.turnOff()
461+
// Living Room Light is now OFF.
453462

454463
bedroomThermostat.turnOn()
464+
// Bedroom Thermostat thermostat is now heating.
455465
bedroomThermostat.adjustTemperature(5)
466+
// Bedroom Thermostat thermostat set to 5°C.
456467
bedroomThermostat.turnOff()
468+
// Bedroom Thermostat thermostat is now off.
457469
}
458470
```
459471
{initial-collapse-state="collapsed" collapsible="true" collapsed-title="Example solution" id="kotlin-tour-classes-interfaces-solution-1"}
@@ -485,6 +497,7 @@ class // Write your code here
485497
fun main() {
486498
val audio = Audio("Symphony No. 5", "Beethoven")
487499
audio.play()
500+
// Playing audio: Symphony No. 5, composed by Beethoven
488501
}
489502
```
490503
{validate="false" kotlin-runnable="true" kotlin-min-compiler-version="1.3" id="kotlin-tour-classes-interfaces-exercise-2"}
@@ -505,6 +518,7 @@ class Audio(override val title: String, val composer: String) : Media {
505518
fun main() {
506519
val audio = Audio("Symphony No. 5", "Beethoven")
507520
audio.play()
521+
// Playing audio: Symphony No. 5, composed by Beethoven
508522
}
509523
```
510524
{initial-collapse-state="collapsed" collapsible="true" collapsed-title="Example solution" id="kotlin-tour-classes-interfaces-solution-2"}
@@ -542,8 +556,11 @@ fun main() {
542556
val visa = CreditCard("Visa")
543557

544558
visa.authorize(100.0)
559+
// Authorizing payment of $100.0.
545560
visa.processPayment(100.0)
561+
// Processing credit card payment of $100.0.
546562
visa.refund(50.0)
563+
// Refunding $50.0 to the credit card.
547564
}
548565
```
549566
{validate="false" kotlin-runnable="true" kotlin-min-compiler-version="1.3" id="kotlin-tour-classes-interfaces-exercise-3"}
@@ -576,8 +593,11 @@ fun main() {
576593
val visa = CreditCard("Visa")
577594

578595
visa.authorize(100.0)
596+
// Authorizing payment of $100.0.
579597
visa.processPayment(100.0)
598+
// Processing credit card payment of $100.0.
580599
visa.refund(50.0)
600+
// Refunding $50.0 to the credit card.
581601
}
582602
```
583603
{initial-collapse-state="collapsed" collapsible="true" collapsed-title="Example solution" id="kotlin-tour-classes-interfaces-solution-3"}
@@ -623,8 +643,12 @@ fun main() {
623643
val smartMessenger = SmartMessenger(basicMessenger)
624644

625645
basicMessenger.sendMessage("Hello!")
646+
// Sending message: Hello!
626647
println(smartMessenger.receiveMessage())
648+
// You've got a new message!
627649
smartMessenger.sendMessage("Hello from SmartMessenger!")
650+
// Sending a smart message: Hello from SmartMessenger!
651+
// Sending message: [smart] Hello from SmartMessenger!
628652
}
629653
```
630654
{validate="false" kotlin-runnable="true" kotlin-min-compiler-version="1.3" id="kotlin-tour-classes-interfaces-exercise-4"}
@@ -658,8 +682,12 @@ fun main() {
658682
val smartMessenger = SmartMessenger(basicMessenger)
659683

660684
basicMessenger.sendMessage("Hello!")
685+
// Sending message: Hello!
661686
println(smartMessenger.receiveMessage())
687+
// You've got a new message!
662688
smartMessenger.sendMessage("Hello from SmartMessenger!")
689+
// Sending a smart message: Hello from SmartMessenger!
690+
// Sending message: [smart] Hello from SmartMessenger!
663691
}
664692
```
665693
{initial-collapse-state="collapsed" collapsible="true" collapsed-title="Example solution" id="kotlin-tour-classes-interfaces-solution-4"}

docs/topics/tour/kotlin-tour-intermediate-lambdas-receiver.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ fun fetchData(callback: StringBuilder.() -> Unit) {
173173
fun main() {
174174
fetchData {
175175
// Write your code here
176+
// Data received - Processed
176177
}
177178
}
178179
```
@@ -189,6 +190,7 @@ fun main() {
189190
fetchData {
190191
append(" - Processed")
191192
println(this.toString())
193+
// Data received - Processed
192194
}
193195
}
194196
```
@@ -224,6 +226,7 @@ fun main() {
224226

225227
button.onEvent {
226228
// Write your code here
229+
// Double click!
227230
}
228231
}
229232
```
@@ -256,6 +259,7 @@ fun main() {
256259
button.onEvent {
257260
if (!isRightClick && amount == 2) {
258261
println("Double click!")
262+
// Double click!
259263
}
260264
}
261265
}

docs/topics/tour/kotlin-tour-intermediate-objects.md

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,20 +185,25 @@ data object OrderOne: Order {
185185
data object // Write your code here
186186
187187
fun main() {
188-
// Print the contents of each data object
189-
println("Order One Details: $OrderOne")
190-
println("Order Two Details: $OrderTwo")
188+
// Print the name of each data object
189+
println("Order name: $OrderOne")
190+
// Order name: OrderOne
191+
println("Order name: $OrderTwo")
192+
// Order name: OrderTwo
191193
192194
// Check if the orders are identical
193195
println("Are the two orders identical? ${OrderOne == OrderTwo}")
196+
// Are the two orders identical? false
194197
195198
if (OrderOne == OrderTwo) {
196199
println("The orders are identical.")
197200
} else {
198201
println("The orders are unique.")
202+
// The orders are unique.
199203
}
200204
201205
println("Do the orders have the same customer name? ${OrderOne.customerName == OrderTwo.customerName}")
206+
// Do the orders have the same customer name? false
202207
}
203208
```
204209
{validate="false" kotlin-runnable="true" kotlin-min-compiler-version="1.3" id="kotlin-tour-objects-exercise-1"}
@@ -224,20 +229,25 @@ data object OrderTwo: Order {
224229
}
225230
226231
fun main() {
227-
// Print the contents of each data object
228-
println("Order One Details: $OrderOne")
229-
println("Order Two Details: $OrderTwo")
232+
// Print the name of each data object
233+
println("Order name: $OrderOne")
234+
// Order name: OrderOne
235+
println("Order name: $OrderTwo")
236+
// Order name: OrderTwo
230237
231238
// Check if the orders are identical
232239
println("Are the two orders identical? ${OrderOne == OrderTwo}")
240+
// Are the two orders identical? false
233241
234242
if (OrderOne == OrderTwo) {
235243
println("The orders are identical.")
236244
} else {
237245
println("The orders are unique.")
246+
// The orders are unique.
238247
}
239248
240249
println("Do the orders have the same customer name? ${OrderOne.customerName == OrderTwo.customerName}")
250+
// Do the orders have the same customer name? false
241251
}
242252
```
243253
{initial-collapse-state="collapsed" collapsible="true" collapsed-title="Example solution" id="kotlin-tour-objects-solution-1"}
@@ -260,7 +270,9 @@ object // Write your code here
260270
261271
fun main() {
262272
println("${FlyingSkateboard.name}: ${FlyingSkateboard.move()}")
273+
// Flying Skateboard: Glides through the air with a hover engine
263274
println("${FlyingSkateboard.name}: ${FlyingSkateboard.fly()}")
275+
// Flying Skateboard: Woooooooo
264276
}
265277
```
266278
{validate="false" kotlin-runnable="true" kotlin-min-compiler-version="1.3" id="kotlin-tour-objects-exercise-2"}
@@ -281,7 +293,9 @@ object FlyingSkateboard : Vehicle {
281293
282294
fun main() {
283295
println("${FlyingSkateboard.name}: ${FlyingSkateboard.move()}")
296+
// Flying Skateboard: Glides through the air with a hover engine
284297
println("${FlyingSkateboard.name}: ${FlyingSkateboard.fly()}")
298+
// Flying Skateboard: Woooooooo
285299
}
286300
```
287301
{initial-collapse-state="collapsed" collapsible="true" collapsed-title="Example solution" id="kotlin-tour-objects-solution-2"}
@@ -310,6 +324,7 @@ fun main() {
310324
val fahrenheit = 90.0
311325
val temp = Temperature.fromFahrenheit(fahrenheit)
312326
println("${temp.celsius}°C is $fahrenheit °F")
327+
// 32.22222222222222°C is 90.0 °F
313328
}
314329
```
315330
{validate="false" kotlin-runnable="true" kotlin-min-compiler-version="1.3" id="kotlin-tour-objects-exercise-3"}
@@ -328,6 +343,7 @@ fun main() {
328343
val fahrenheit = 90.0
329344
val temp = Temperature.fromFahrenheit(fahrenheit)
330345
println("${temp.celsius}°C is $fahrenheit °F")
346+
// 32.22222222222222°C is 90.0 °F
331347
}
332348
```
333349
{initial-collapse-state="collapsed" collapsible="true" collapsed-title="Example solution" id="kotlin-tour-objects-solution-3"}

docs/topics/tour/kotlin-tour-intermediate-open-special-classes.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,9 +432,13 @@ fun main() {
432432
val status4: DeliveryStatus = DeliveryStatus.Canceled("Address not found")
433433

434434
printDeliveryStatus(status1)
435+
// The package is pending pickup from Alice.
435436
printDeliveryStatus(status2)
437+
// The package is in transit and expected to arrive by 2024-11-20.
436438
printDeliveryStatus(status3)
439+
// The package was delivered to Bob on 2024-11-18.
437440
printDeliveryStatus(status4)
441+
// The delivery was canceled due to: Address not found.
438442
}
439443
```
440444
{validate="false" kotlin-runnable="true" kotlin-min-compiler-version="1.3" id="kotlin-tour-special-classes-exercise-1"}
@@ -472,9 +476,13 @@ fun main() {
472476
val status4: DeliveryStatus = DeliveryStatus.Canceled("Address not found")
473477

474478
printDeliveryStatus(status1)
479+
// The package is pending pickup from Alice.
475480
printDeliveryStatus(status2)
481+
// The package is in transit and expected to arrive by 2024-11-20.
476482
printDeliveryStatus(status3)
483+
// The package was delivered to Bob on 2024-11-18.
477484
printDeliveryStatus(status4)
485+
// The delivery was canceled due to: Address not found.
478486
}
479487
```
480488
{initial-collapse-state="collapsed" collapsible="true" collapsed-title="Example solution" id="kotlin-tour-special-classes-solution-1"}

docs/topics/tour/kotlin-tour-intermediate-properties.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ updating a UI or to perform additional checks, like verifying the validity of da
424424

425425
For more information, see [Observable properties](delegated-properties.md#observable-properties).
426426

427-
## Properties practice
427+
## Practice
428428

429429
### Exercise 1 {initial-collapse-state="collapsed" collapsible="true" id="properties-exercise-1"}
430430

0 commit comments

Comments
 (0)