Created
October 28, 2022 09:52
-
-
Save Detective-Khalifah/0665104f5ddf9fd22c166a4033f13cce to your computer and use it in GitHub Desktop.
Stage 1 Task: Mobile
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
package hngi9 | |
class Circle { | |
var radius: Double | |
var color: String | |
internal constructor() { | |
radius = 1.0 | |
color = "red" | |
} | |
internal constructor(radius: Double) { | |
this.radius = radius | |
color = "red" | |
} | |
internal constructor(radius: Double, color: String) { | |
this.radius = radius | |
this.color = color | |
} | |
val area: Double | |
get() = Math.PI * Math.pow(radius, 2.0) | |
val circumference: Double | |
get() = 2 * Math.PI * radius | |
val description: String | |
get() = "Radius " + radius.toInt() + " Color " + color | |
val getColor: String | |
get() = color; | |
} |
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
package hngi9 | |
object Inflate { | |
@JvmStatic | |
fun main(args: Array<String>) { | |
// Get reference to the {@link Circle} objects. | |
val circle3 = Circle(2.0, "blue") | |
val circle2 = Circle(2.0) | |
val circle1 = Circle() | |
// Print deets of {@link Circle} 1 | |
System.out.printf( | |
"Circle 1: \nArea: %.15f\nCircumference: %.15f\nDescription: %s\nColor: %s\n\n", | |
circle1.area, circle1.circumference, circle1.description, circle1.getColor | |
) | |
// Print deets of {@link Circle} 2 | |
System.out.printf( | |
"Circle 2: \nArea: %.15f\nCircumference: %.15f\nDescription: %s\nColor: %s\n\n", | |
circle2.area, circle2.circumference, circle2.description, circle2.getColor | |
) | |
// Print deets of {@link Circle} 3 | |
System.out.printf( | |
"Circle 3: \nArea: %.15f\nCircumference: %.15f\nDescription: %s\nColor: %s", | |
circle3.area, circle3.circumference, circle3.description, circle3.getColor | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment