Last active
October 26, 2020 16:58
-
-
Save sodogan/c58e1dfd855d4cad9d852ea6694245ed to your computer and use it in GitHub Desktop.
This file contains 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
import 'dart:math' as math; | |
class Circle { | |
double _radius; | |
Circle({double radius=0.0}){ | |
this._radius = radius; | |
} | |
//getters | |
double get radius=>this._radius; | |
double get area => math.pi * math.pow(this._radius, 2); | |
//setters | |
void set radius(double radius)=>this._radius = radius; | |
} | |
void main() { | |
var circ1 = Circle(radius:1.23); | |
print('Radius before ${circ1.radius}'); | |
//setter | |
circ1.radius = 12; | |
print('Radius after: ${circ1.radius}'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment