Created
October 23, 2020 21:10
-
-
Save jakazzy/54828a913a077c4c20e1b45a94d88176 to your computer and use it in GitHub Desktop.
Classes in dart
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
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