Skip to content

Instantly share code, notes, and snippets.

@cioccarellia
Last active August 1, 2020 13:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cioccarellia/bb24c49b2753c9600d79172e3862d113 to your computer and use it in GitHub Desktop.
Save cioccarellia/bb24c49b2753c9600d79172e3862d113 to your computer and use it in GitHub Desktop.
val mountain = Mountain().apply {
treeCount = randomBetween(2000, 3000)
houseCount = randomBetween(5, 10)
pendence = 20/100
roadKind = RoadKind.DIRT
}
val leavesToHouseRatio: Float = mountain.run {
val totalLeaves = treeCount * TREE_LEAVES_COUNT
val houseSurface = houseList.map {
it.squareMeters
}.sum()
// Last statement
if (houseCount > 0) {
totalLeaves / houseSurface
} else {
0
}
}
// We run functions but don't care about the result
mountain.run {
printHousePosition()
printTreesPosition()
printStreetPath()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment