Skip to content

Instantly share code, notes, and snippets.

@kwalrath
Last active August 9, 2022 05:41
Show Gist options
  • Save kwalrath/a81cf6bde4d52bb8b774d87aff842b56 to your computer and use it in GitHub Desktop.
Save kwalrath/a81cf6bde4d52bb8b774d87aff842b56 to your computer and use it in GitHub Desktop.
Java-to-Dart codelab: Final Bicycle example
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