Skip to content

Instantly share code, notes, and snippets.

@naushad-madakiya
Last active May 15, 2018 02:31
Show Gist options
  • Save naushad-madakiya/84a8977fa3727eaa55f7c4897a0f4b17 to your computer and use it in GitHub Desktop.
Save naushad-madakiya/84a8977fa3727eaa55f7c4897a0f4b17 to your computer and use it in GitHub Desktop.
Intro to Dart for Java Developers Codelab: Simple Dart Class
class Bicycle {
int cadence;
int _speed = 0;
int gear;
Bicycle(this.cadence, this.gear);
int get speed => _speed;
void applyBrake(int decrement) => _speed -= decrement;
void speedUp(int increment) => _speed += increment;
@override
String toString() => "Bicycle: $_speed mph";
}
void main() {
var bike = new Bicycle(2, 3);
print(bike);
}
@naushad-madakiya
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment