-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSession7.dart
More file actions
52 lines (36 loc) · 1000 Bytes
/
Session7.dart
File metadata and controls
52 lines (36 loc) · 1000 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
42
43
44
45
46
47
48
49
50
51
52
abstract class Notification{
void onNotification(String message);
}
class YoutubeChannel{
Notification? notification;
void subsribe(User user){
notification = user; // Polymorphism
// notification is a reference which is now pointing to the object of User
}
void uploadNewVideo(String title){
print("Upload Started....");
print("Upload Finished....");
notification!.onNotification("A new Video has been uploaded ${title}");
}
}
class User extends Notification{
String? name;
String? email;
User({this.name, this.email});
@override
String toString() {
return "${name} | ${email}";
}
void onNotification(String message){
print("~~~~~~~~~~~~~~~~~");
print("New Notification");
print(message);
print("~~~~~~~~~~~~~~~~~");
}
}
void main(){
YoutubeChannel channel = YoutubeChannel();
User user1 = User(name: "John", email: "john@example.com");
channel.subsribe(user1);
channel.uploadNewVideo("Intro to OOPS :)");
}