Skip to content

Instantly share code, notes, and snippets.

@sieleemmanuel
Last active October 31, 2022 11:48
Show Gist options
  • Save sieleemmanuel/44811f65ed62d7cc05500637d00fbe34 to your computer and use it in GitHub Desktop.
Save sieleemmanuel/44811f65ed62d7cc05500637d00fbe34 to your computer and use it in GitHub Desktop.
Hng9 Stage-1-Task-Mobile
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()
}
@sieleemmanuel
Copy link
Author

Hni9 Internship Stage 1 Mobile Tasks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment