Created
February 8, 2020 11:26
-
-
Save angwandi/188718bad13606ffa51b3126f7421773 to your computer and use it in GitHub Desktop.
inheriting in Dart
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
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