Skip to content

Instantly share code, notes, and snippets.

@sodogan
Last active October 26, 2020 16:58
Show Gist options
  • Save sodogan/c58e1dfd855d4cad9d852ea6694245ed to your computer and use it in GitHub Desktop.
Save sodogan/c58e1dfd855d4cad9d852ea6694245ed to your computer and use it in GitHub Desktop.
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