Last active
October 31, 2022 11:48
-
-
Save sieleemmanuel/44811f65ed62d7cc05500637d00fbe34 to your computer and use it in GitHub Desktop.
Hng9 Stage-1-Task-Mobile
This file contains hidden or 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
data class Circle(val radius:Double = 1.0, val color: String = "red"){ | |
private val PI = 3.14159265359 | |
fun getArea() = "Area: ${PI*radius*radius}" | |
fun getCircumference() = "Circumference: ${PI*radius*2}" | |
fun getDescription() = "Description: Radius: ${radius.toInt()} Color: $color " | |
fun getCircleColor() = "Color: $color" | |
} | |
fun main() { | |
val circle1 = Circle() | |
val circle2 = Circle(1.0) | |
val circle3 = Circle(1.0, "blue") | |
getCircle("Circle 1", circle1) | |
getCircle("Circle 2", circle2) | |
getCircle("Circle 3", circle3) | |
} | |
fun getCircle(name:String, circle: Circle){ | |
println("$name:") | |
println(circle.getArea()) | |
println(circle.getCircumference()) | |
println(circle.getDescription()) | |
println(circle.getCircleColor()) | |
println() | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hni9 Internship Stage 1 Mobile Tasks