Skip to content

Instantly share code, notes, and snippets.

@kalbliz
Created October 28, 2022 08:31
Show Gist options
  • Save kalbliz/38af32b554995b521a715a77b73ff830 to your computer and use it in GitHub Desktop.
Save kalbliz/38af32b554995b521a715a77b73ff830 to your computer and use it in GitHub Desktop.
hng 9, task 1
class Circle {
double radius;
String color;
Circle({this.radius = 1, this.color = 'red'});
}
Circle circle1 = Circle();
Circle circle2 = Circle(radius: 2);
Circle circle3 = Circle(radius: 2, color: 'blue');
getCircumference(double rad) {
final circumference = 2 * rad * 3.14;
return circumference;
}
getDescription(double rad, String color) {
final description = 'Description: Radius: $rad Color: $color';
return description;
}
getColor(String circlecolor) {
final color = circlecolor;
return color;
}
getArea(double rad) {
final area = rad * rad * 3.141592653589793;
return area;
}
printCircle1() {
print('Circle 1:');
print('Area: ${getArea(circle1.radius)}');
print('Circumference: ${getCircumference(circle1.radius)}');
print('Description: ${getDescription(circle1.radius, circle1.color)}');
print('Color : ${getColor(circle1.color)}');
}
printCircle2() {
print('Circle 2:');
print('Area: ${getArea(circle2.radius)}');
print('Circumference: ${getCircumference(circle2.radius)}');
print('Description: ${getDescription(circle2.radius, circle2.color)}');
print('Color : ${getColor(circle2.color)}');
}
printCircle3() {
print('Circle 3:');
print('Area: ${getArea(circle3.radius)}');
print('Circumference: ${getCircumference(circle3.radius)}');
print('Description: ${getDescription(circle3.radius, circle3.color)}');
print('Color : ${getColor(circle3.color)}');
}
void main() {
printCircle1();
print('');
printCircle2();
print('');
printCircle3();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment