Created
July 27, 2020 11:23
-
-
Save ochim/89fbf32db5ba8788678304ad7d51cdd8 to your computer and use it in GitHub Desktop.
birthdayCake.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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