Created with <3 with dartpad.dev.
Last active
October 27, 2022 20:22
-
-
Save ezeanyimhenry/c611c84ddddcdb51ce842d8401e734a6 to your computer and use it in GitHub Desktop.
fascinating-rose-0694
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
| import 'dart:math'; | |
| class Circle { | |
| double radius; | |
| String color; | |
| Circle() : radius=1, color="red"; | |
| Circle.onlyRadius(this.radius) : color="red"; | |
| Circle.both(this.radius, this.color); | |
| getArea(){ | |
| return (pow(radius, 2) * pi); | |
| } | |
| getCircumference(){ | |
| return (2 * pi * radius); | |
| } | |
| getDescription(){ | |
| return ("Radius: $radius Color: $color"); | |
| } | |
| getColor(){ | |
| return (color); | |
| } | |
| } | |
| void main() { | |
| Circle circle1 = Circle(); | |
| print ("Circle 1:"); | |
| print("Area: ${circle1.getArea()}"); | |
| print("Circumference: ${circle1.getCircumference()}"); | |
| print("Description: ${circle1.getDescription()}"); | |
| print("Color: ${circle1.getColor()}"); | |
| Circle circle2 = Circle.onlyRadius(2); | |
| print ("Circle 2:"); | |
| print("Area: ${circle2.getArea()}"); | |
| print("Circumference: ${circle2.getCircumference()}"); | |
| print("Description: ${circle2.getDescription()}"); | |
| print("Color: ${circle2.getColor()}"); | |
| Circle circle3 = Circle.both(2, "blue"); | |
| print ("Circle 3:"); | |
| print("Area: ${circle3.getArea()}"); | |
| print("Circumference: ${circle3.getCircumference()}"); | |
| print("Description: ${circle3.getDescription()}"); | |
| print("Color: ${circle3.getColor()}"); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment