Skip to content

Instantly share code, notes, and snippets.

@nunomazer
Created March 27, 2020 21:50
Show Gist options
  • Save nunomazer/b6287726ecf495662aa23b11af25c2d2 to your computer and use it in GitHub Desktop.
Save nunomazer/b6287726ecf495662aa23b11af25c2d2 to your computer and use it in GitHub Desktop.
Exemplo Dart herança
class Television {
void _illuminateDisplay() {
print ("Display ON");
}
void _activateIrSensor() {
print ("IR sensor ON");
}
void turnOn() {
_illuminateDisplay();
_activateIrSensor();
}
}
class SmartTelevision extends Television {
void _bootNetworkInterface() {
print ("Network booted");
}
void _initializeMemory() {
print ("Reading memory");
print ("X memory ready");
}
void _upgradeApps() {
print ("Checking Apps new versions");
}
void turnOn() {
super.turnOn();
_bootNetworkInterface();
_initializeMemory();
_upgradeApps();
}
}
void main () {
Television t = new Television();
print("Turning on Television");
t.turnOn();
print("");
print("Turning on SmartTv");
SmartTelevision s = new SmartTelevision();
s.turnOn();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment