Skip to content

Instantly share code, notes, and snippets.

@Hackathonwave
Created September 20, 2023 13:22
Show Gist options
  • Save Hackathonwave/ac5f30542e92267879350f0c98e4de26 to your computer and use it in GitHub Desktop.
Save Hackathonwave/ac5f30542e92267879350f0c98e4de26 to your computer and use it in GitHub Desktop.
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