Skip to content

Commit

Permalink
Merge pull request #1351 from datou0412/master
Browse files Browse the repository at this point in the history
Add koltin sample for website
  • Loading branch information
alexdima committed Sep 19, 2019
2 parents b3ca138 + 94a5d3b commit 1579caf
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions website/index/samples/sample.kotlin.txt
@@ -0,0 +1,28 @@
const val POINTS_X_PASS: Int = 15
val EZPassAccounts: MutableMap<Int, Int> = mutableMapOf(1 to 100, 2 to 100, 3 to 100)
val EZPassReport: Map<Int, Int> = EZPassAccounts

// update points credit
fun updatePointsCredit(accountId: Int) {
if (EZPassAccounts.containsKey(accountId)) {
println("Updating $accountId...")
EZPassAccounts[accountId] = EZPassAccounts.getValue(accountId) + POINTS_X_PASS
} else {
println("Error: Trying to update a non-existing account (id: $accountId)")
}
}

fun accountsReport() {
println("EZ-Pass report:")
EZPassReport.forEach{
k, v -> println("ID $k: credit $v")
}
}

fun main() {
accountsReport()
updatePointsCredit(1)
updatePointsCredit(1)
updatePointsCredit(5)
accountsReport()
}

0 comments on commit 1579caf

Please sign in to comment.