Created
January 21, 2019 03:03
-
-
Save marti1125/865dd958ecf0489b37f33e3eca783175 to your computer and use it in GitHub Desktop.
bicycle.dart
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
class Bicycle { | |
int cadence; | |
int _speed = 0; | |
int get speed => _speed; | |
int gear; | |
Bicycle(int cadence, int gear) { | |
this.cadence = cadence; | |
this.gear = gear; | |
} | |
void applyBrake(int decrement) { | |
_speed -= decrement; | |
} | |
void speedUp(int increment) { | |
_speed += increment; | |
} | |
@override | |
String toString() => 'Bicycle: $speed mph'; | |
} | |
| |
void main() { | |
var bike = new Bicycle(0, 1); | |
print(bike); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment