Skip to content

Instantly share code, notes, and snippets.

@angwandi
Created February 8, 2020 11:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save angwandi/188718bad13606ffa51b3126f7421773 to your computer and use it in GitHub Desktop.
Save angwandi/188718bad13606ffa51b3126f7421773 to your computer and use it in GitHub Desktop.
inheriting in Dart
void main(){
Car normal = Car();
print(normal.numberOfSeat);
normal.drive();
ElectricCar myTesla = ElectricCar();
myTesla.drive();
myTesla.recharge();
}
class Car{
int numberOfSeat = 5;
void drive(){
print('Wheels turn.');
}
}
class ElectricCar extends Car{
int batteryLevel = 100;
void recharge(){
batteryLevel = 100;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment