Skip to content

Instantly share code, notes, and snippets.

@jakazzy
Created October 23, 2020 21:10
Show Gist options
  • Save jakazzy/54828a913a077c4c20e1b45a94d88176 to your computer and use it in GitHub Desktop.
Save jakazzy/54828a913a077c4c20e1b45a94d88176 to your computer and use it in GitHub Desktop.
Classes in dart
void main() {
var volume = Cylinder.cylinderVolume(5, 7);
var surfaceAreaTotal = Cylinder.totalSurfaceArea(5, 7);
var surfaceAreaCurved = Cylinder.curvedSurfaceArea(5,7);
print("The volume of the cylinder is ${volume}");
print("The Total surface area of the cylinder is ${surfaceAreaTotal}");
print("The curved surface area of the cylinder is ${surfaceAreaCurved}");
}
class Cylinder{
int baseRadius;
int height;
Cylinder({ this.baseRadius, this.height});
static cylinderVolume(baseRadius, height){
return 3.14 * baseRadius * baseRadius * height;
}
static totalSurfaceArea(baseRadius, height){
return 2 * 3.14 * baseRadius * height * (baseRadius + height);
}
static curvedSurfaceArea(baseRadius, height){
return 2 * 3.14 * baseRadius * height;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment