Created
September 20, 2023 13:22
-
-
Save Hackathonwave/ac5f30542e92267879350f0c98e4de26 to your computer and use it in GitHub Desktop.
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
void main() { | |
//Car myNormalCar = Car(); | |
//print(myNormalCar.numberOfSeat); | |
//myNormalCar.drive(); | |
//ElectricCar myTesla = ElectricCar(); | |
//myTesla.drive(); | |
//myTesla.recharge(); | |
//LevitatingCar myMagLev = LevitatingCar(); | |
//myMagLev.drive(); | |
SelfDrivingCar myWaymo = SelfDrivingCar('1 Hacker way'); | |
myWaymo.drive(); | |
} | |
class Car { | |
int numberOfSeat = 4; | |
void drive() { | |
print('Wheels turn.'); | |
} | |
} | |
class ElectricCar extends Car { | |
int batteryLevel = 100; | |
void recharge() { | |
batteryLevel = 100; | |
} | |
} | |
class LevitatingCar extends Car { | |
@override | |
void drive() { | |
print('glides forward'); | |
} | |
} | |
class SelfDrivingCar extends Car { | |
late String destination; | |
SelfDrivingCar(String userSetDestination) { | |
destination = userSetDestination; | |
} | |
@override | |
void drive() { | |
super.drive(); | |
print('Sterring towards $destination'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment