Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Car{
- int noOfSeat=4;
- void drive() {
- print("this is driving");
- }
- }
- class ElectricCar extends Car{
- int batteryLevel=0;
- void recharge(){
- this.batteryLevel=100;
- print('Charging is %100');
- }
- }
- class SelfDrivingCar extends Car{
- String destination;
- SelfDrivingCar({this.destination});
- @override
- void dive() {
- super.drive();
- print("the car is moving to $destination");
- }
- }
- void main(){
- var normal= Car();
- normal.drive();
- var tesla=ElectricCar();
- tesla.drive();
- var myWaymo = SelfDrivingCar(destination: "Bazzar");
- myWaymo.drive();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement