Skip to content

Commit 57fd86d

Browse files
ctruchiCLOVIS-AI
authored andcommitted
tp1 solution
1 parent 3520356 commit 57fd86d

File tree

1 file changed

+12
-8
lines changed
  • tp1/src/main/kotlin/fmt/kotlin/fundamentals

1 file changed

+12
-8
lines changed

tp1/src/main/kotlin/fmt/kotlin/fundamentals/Tp1.kt

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,44 @@ package fmt.kotlin.fundamentals
33
var x = 0
44

55
fun incrementXAndReturnOldValue(): Int {
6-
return -1
6+
return x++
77
}
88

99
fun incrementXAndReturnNewValue(): Int {
10-
return -1
10+
return ++x
1111
}
1212

1313
fun sumZeroPointFive(): Float {
14-
return -1f
14+
return x + 0.5f
1515
}
1616

1717
fun subtractBigNumber(): Int {
18-
return -1
18+
return x - 1_854_643
1919
}
2020

2121
fun buildRangeOpen(): IntRange {
22-
return 0..0
22+
return 1..42
2323
}
2424

2525
fun buildRangeOpenEnded(): IntRange {
26-
return 0..0
26+
return 1..<42
2727
}
2828

2929
/**
3030
* n Number of bottles. Always more than 2.
3131
*/
3232
fun describeNbBottles(): String {
33-
return ""
33+
return "There are $x bottles"
3434
}
3535

3636
var totalBottles = 0
3737
var nbWhiteBottles = 0
3838
var nbRedBottles = 0
3939

4040
fun describeWithDetailNbBottles(): String {
41-
return ""
41+
return """
42+
There are $totalBottles bottles :
43+
- $nbWhiteBottles bottles of white
44+
- $nbRedBottles bottles of red
45+
""".trimIndent()
4246
}

0 commit comments

Comments
 (0)