Created with <3 with dartpad.dev.
Created
October 31, 2022 14:13
-
-
Save devRaphe/441d07068ef94b59e67e1e9b3ea7ba3e to your computer and use it in GitHub Desktop.
silent-marble-5507
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
void main() { | |
Circle circle1 = Circle(); | |
Circle circle2 = Circle.second(12.4); | |
Circle circle3 = Circle.third(radius: 22.3, color: 'blue'); | |
print(''' | |
Circle 1: | |
Area: ${circle1.getArea()}; | |
Circumference: ${circle1.getCircumference()} | |
Description: ${circle1.getDescription()} | |
Color: ${circle1.getColor()} | |
Circle 2: | |
Area: ${circle2.getArea()}; | |
Circumference: ${circle2.getCircumference()} | |
Description: ${circle2.getDescription()} | |
Color: ${circle2.getColor()} | |
Circle 3: | |
Area: ${circle3.getArea()}; | |
Circumference: ${circle3.getCircumference()} | |
Description: ${circle3.getDescription()} | |
Color: ${circle3.getColor()} | |
'''); | |
} | |
const double PI = 3.14; | |
class Circle { | |
double? radius; | |
String? color; | |
Circle() | |
: radius = 1, | |
color = 'red'; | |
Circle.second(this.radius) : color = 'red'; | |
Circle.third({required this.radius, required this.color}); | |
double? getArea() { | |
return PI * radius! * radius!; | |
} | |
double? getCircumference() { | |
if (radius != null) { | |
return 2 * PI * radius!; | |
} | |
return null; | |
} | |
String? getDescription() { | |
return 'Radius: $radius Color: $color'; | |
} | |
String getColor() { | |
return 'Color: $color'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment