Skip to content

Instantly share code, notes, and snippets.

@ochim
Created July 27, 2020 11:23
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 ochim/89fbf32db5ba8788678304ad7d51cdd8 to your computer and use it in GitHub Desktop.
Save ochim/89fbf32db5ba8788678304ad7d51cdd8 to your computer and use it in GitHub Desktop.
birthdayCake.kt
// Android Basics: Introduction to Kotlin
fun main() {
val age = 24
val layers = 5
printCakeCandles(age)
printCakeTop(age)
printCakeBottom(age, layers)
}
fun printCakeTop(age: Int) {
repeat(age + 2) {
print("=")
}
println()
}
fun printCakeCandles(age: Int) {
print (" ")
repeat(age) {
print(",")
}
println() // Print an empty line
print(" ") // Print the inset of the candles on the cake
repeat(age) {
print("|")
}
println()
}
fun printCakeBottom(age: Int, layers: Int) {
repeat(layers) {
repeat(age + 2) {
print("@")
}
println()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment