Created
October 29, 2022 01:43
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 'package:flutter/foundation.dart'; | |
import 'dart:math'; | |
void main() { | |
// The output should look like this: | |
print('Circle 2'); | |
Circle circle1 = Circle(); | |
circle1.setRadius = 1.0; | |
circle1.setColor = 'red'; | |
print("Area: ${circle1.getArea()}"); | |
print("Circumference: ${circle1.getCircumference()}"); | |
print("Description: ${circle1.getDescription()}"); | |
print("Color: ${circle1.getColor()}"); | |
// ///////////////////////////////////////////////////////////////////////////////////// | |
/////////////////////////////////////////////////////////////////////////// | |
////////////////////////////////////////////////////// | |
print('Circle 2'); | |
Circle circle2 = Circle(7.0); | |
circle1.setColor = 'red'; | |
print("Area: ${circle1.getArea()}"); | |
print("Circumference: ${circle1.getCircumference()}"); | |
print("Description: ${circle1.getDescription()}"); | |
print("Color: ${circle1.getColor()}"); | |
// ///////////////////////////////////////////////////////////////////////////////////// | |
/////////////////////////////////////////////////////////////////////////// | |
////////////////////////////////////////////////////// | |
print('Circle 3'); | |
Circle circle3 = Circle(5.0, 'green'); | |
print("Area: ${circle1.getArea()}"); | |
print("Circumference: ${circle1.getCircumference()}"); | |
print("Description: ${circle1.getDescription()}"); | |
print("Color: ${circle1.getColor()}"); | |
} | |
class Circle { | |
double radius; | |
String color; | |
Circle([ | |
this.radius = 0.0, | |
this.color = '', | |
]); | |
set setColor(String inputColor) => color = inputColor; | |
set setRadius(double inputRadius) => radius = inputRadius; | |
double getArea() { | |
return pi * pow(radius, 2); | |
} | |
double getCircumference() { | |
return 2 * pi * radius; | |
} | |
String getColor() { | |
return color; | |
} | |
String getDescription() { | |
return ' radius: $radius , color: ${color}'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hng task one