Created with <3 with dartpad.dev.
Created
October 28, 2022 23:16
-
-
Save KcPele/5082f673c1c50818a53729a8043459e2 to your computer and use it in GitHub Desktop.
hngi9
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
class Circle { | |
static const pie = 3.142; | |
double Radius; | |
String Color; | |
Circle.noValues() : Radius = 1, Color="red"; | |
Circle.onlyRadius(this.Radius) : Color = "red"; | |
Circle(this.Radius, this.Color); | |
String getArea() { | |
return "Area: ${Circle.pie * (Radius * Radius)}"; | |
} | |
String getCircumference() { | |
return "Circumference: ${2 * Circle.pie * Radius}"; | |
} | |
String getDescription() { | |
return "Description: Radius: $Radius Color: $Color"; | |
} | |
String getColor() { | |
return "Color: $Color"; | |
} | |
} | |
void main() { | |
print("Circle 1:"); | |
Circle circle1 = Circle.noValues(); | |
print(circle1.getArea()); | |
print(circle1.getCircumference()); | |
print(circle1.getDescription()); | |
print(circle1.getColor()); | |
print("\n"); | |
print("Circle 2:"); | |
Circle circle2 = Circle.onlyRadius(2); | |
print(circle2.getArea()); | |
print(circle2.getCircumference()); | |
print(circle2.getDescription()); | |
print(circle2.getColor()); | |
print("\n"); | |
print("Circle 3:"); | |
Circle circle3 = Circle(3, 'blue'); | |
print(circle3.getArea()); | |
print(circle3.getCircumference()); | |
print(circle3.getDescription()); | |
print(circle3.getColor()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment