Skip to content

Instantly share code, notes, and snippets.

@ezeanyimhenry
Last active October 27, 2022 20:22
Show Gist options
  • Select an option

  • Save ezeanyimhenry/c611c84ddddcdb51ce842d8401e734a6 to your computer and use it in GitHub Desktop.

Select an option

Save ezeanyimhenry/c611c84ddddcdb51ce842d8401e734a6 to your computer and use it in GitHub Desktop.
fascinating-rose-0694

fascinating-rose-0694

Created with <3 with dartpad.dev.

import 'dart:math';
class Circle {
double radius;
String color;
Circle() : radius=1, color="red";
Circle.onlyRadius(this.radius) : color="red";
Circle.both(this.radius, this.color);
getArea(){
return (pow(radius, 2) * pi);
}
getCircumference(){
return (2 * pi * radius);
}
getDescription(){
return ("Radius: $radius Color: $color");
}
getColor(){
return (color);
}
}
void main() {
Circle circle1 = Circle();
print ("Circle 1:");
print("Area: ${circle1.getArea()}");
print("Circumference: ${circle1.getCircumference()}");
print("Description: ${circle1.getDescription()}");
print("Color: ${circle1.getColor()}");
Circle circle2 = Circle.onlyRadius(2);
print ("Circle 2:");
print("Area: ${circle2.getArea()}");
print("Circumference: ${circle2.getCircumference()}");
print("Description: ${circle2.getDescription()}");
print("Color: ${circle2.getColor()}");
Circle circle3 = Circle.both(2, "blue");
print ("Circle 3:");
print("Area: ${circle3.getArea()}");
print("Circumference: ${circle3.getCircumference()}");
print("Description: ${circle3.getDescription()}");
print("Color: ${circle3.getColor()}");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment