Skip to content

Instantly share code, notes, and snippets.

@dimeprog
Created October 29, 2022 02:02
Show Gist options
  • Save dimeprog/3287459eeb47ee8ac592f5251014d470 to your computer and use it in GitHub Desktop.
Save dimeprog/3287459eeb47ee8ac592f5251014d470 to your computer and use it in GitHub Desktop.
import 'package:flutter/foundation.dart';
import 'dart:math';
void main() {
// The output should look like this:
print('Circle 1');
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(2.0);
circle1.setColor = 'red';
print("Area: ${circle2.getArea()}");
print("Circumference: ${circle2.getCircumference()}");
print("Description: ${circle2.getDescription()}");
print("Color: ${circle2.getColor()}");
// /////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////
print('Circle 3');
Circle circle3 = Circle(2.0, 'blue');
print("Area: ${circle3.getArea()}");
print("Circumference: ${circle3.getCircumference()}");
print("Description: ${circle3.getDescription()}");
print("Color: ${circle3.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}';
}
}
@dimeprog
Copy link
Author

HNG i9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment