Skip to content

Instantly share code, notes, and snippets.

@eltray
Created August 1, 2019 15:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eltray/9fbaca957fbedf17a01c88dab306caac to your computer and use it in GitHub Desktop.
Save eltray/9fbaca957fbedf17a01c88dab306caac to your computer and use it in GitHub Desktop.
Learning Dart - 1 Introduction
class Bicycle {
int _speed = 0;
int get speed => _speed;
int cadence;
int wheel;
Bicycle({this.cadence = 0, this.wheel = 0});
@override
String toString() =>
'Bicycle: \n Speed is $speed km/h' +
'\n Cadence is $cadence km/h' +
'\n Wheel is $wheel km/h';
void applyBrake(int decrement) {
_speed -= decrement;
}
void speedUp(int increment) {
_speed += increment;
}
}
void main() {
var bike = Bicycle(cadence: 50);
bike.applyBrake(5);
bike.speedUp(10);
print(bike);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment