Created
May 26, 2021 18:22
-
-
Save siumhossain/daeff9628a84f2abc9e066638a65d82b to your computer and use it in GitHub Desktop.
polymorphism
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 car = Car(); | |
| car.drive(); | |
| ElectricCar ecar = ElectricCar('to notunbazar'); | |
| ecar.drive(); | |
| } | |
| class Car{ | |
| void drive(){ | |
| print('turn'); | |
| } | |
| } | |
| class ElectricCar extends Car{ | |
| String destination=''; | |
| ElectricCar(String userdestination){ | |
| destination = userdestination; | |
| } | |
| @override | |
| void drive(){ | |
| super.drive(); | |
| print('charge and $destination'); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment