Last active
May 15, 2018 02:31
-
-
Save naushad-madakiya/84a8977fa3727eaa55f7c4897a0f4b17 to your computer and use it in GitHub Desktop.
Intro to Dart for Java Developers Codelab: Simple Dart Class
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 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); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Execute: https://dartpad.dartlang.org/84a8977fa3727eaa55f7c4897a0f4b17