Created
March 3, 2021 13:02
-
-
Save inialdan/0088f505aa21152e3948175ded469724 to your computer and use it in GitHub Desktop.
Aldan 065118112 - Simple Dart Class
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
class Bicycle { | |
int cadence; | |
int _speed = 0; | |
int get speed => _speed; | |
int gear; | |
Bicycle(this.cadence, this.gear); | |
void applyBrake(int decrement) { | |
_speed -= decrement; | |
} | |
void speedUp(int increment) { | |
_speed += increment; | |
} | |
@override | |
String toString() => 'Bicycle: $_speed mph'; | |
} | |
void main() { | |
var bike = Bicycle(2, 1); | |
print(bike); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment