1
1
Fork 0

Improved the wording for 'Summary 1 ex 10' description

based on https://github.com/BruceEckel/AtomicKotlinExamples/issues/20
This commit is contained in:
Svetlana Isakova 2021-07-20 17:39:12 +02:00
parent 96e21f6122
commit 09aa533a41
3 changed files with 19 additions and 3 deletions

View File

@ -17,9 +17,14 @@ fun showSnake(rows: Int, columns: Int) {
}
fun main() {
showSnake(2, 3)
println()
showSnake(4, 5)
}
/* Output:
0 1 2
5 4 3
0 1 2 3 4
9 8 7 6 5
10 11 12 13 14

View File

@ -10,5 +10,15 @@ filled with sequential numbers in a form of snake. For example, `showSnake(3,
6 7 8
```
For proper alignment, use `"%3d".format(number)` to place any necessary spaces
before the number.
For proper alignment, use a format string such as `"%3d".format(number)` to
place additional spaces before the number. The number before `d` indicates how
many characters the number should occupy together with the additional spaces.
It depends on the biggest number, the last one: put exactly one space before it.
<div class="hint">
Use the string `"%${width}d".format(value)`, where the `width` variable stores
the width of each number cell, to format the value based on the actual input
(`rows` and `columns`).
</div>

View File

@ -10,7 +10,8 @@ import util.runAndCheckSystemOutput
class TestSummaryIExercise10 {
private fun checkOutput(rows: Int, columns: Int, expected: String) {
runAndCheckSystemOutput(
"Incorrect output for rows = $rows, columns = $columns:",
"Incorrect output for rows = $rows, columns = $columns " +
"(pay attention to the spaces!):",
expected) {
showSnake(rows, columns)
}