-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAppliance.dart
More file actions
41 lines (32 loc) · 931 Bytes
/
Appliance.dart
File metadata and controls
41 lines (32 loc) · 931 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
void main(){
print(" **** Module 5 – Assignment **** ");
print(" ");
// Create Fan object and call its methods
Appliance myFan = Fan();
myFan.turnOn();
myFan.turnOff();
print(" ");
// Create Light object and call its methods
Appliance myLight = Light();
myLight.turnOn();
myLight.turnOff();
}
// --------------------- Appliance Abstract Class ---------------------
abstract class Appliance {
void turnOn(); // abstract method
void turnOff(); // abstract method
}
// --------------------- Fan Class ---------------------
class Fan extends Appliance{
@override
void turnOn() => print("The Fan is now on.");
@override
void turnOff() => print("The Fan is switched Off.");
}
// --------------------- Light Class ---------------------
class Light extends Appliance{
@override
void turnOn() => print("The Light is now on.");
@override
void turnOff() => print("The Light is switched Off.");
}