-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path014_extends.dart
97 lines (82 loc) · 2.56 KB
/
014_extends.dart
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/* =============================================================================
# Author: Abdulkerim Akan - https://github.com/kerim47/
# Email: [email protected]
# FileName: 014_extends.dart
# Description: /
# Version: 0.0.1
# History:
============================================================================= */
class Television {
void _illuminateDisplay() {
print("Ekranı aydınlatma işlemini burada gerçekleştirin.");
}
void _activateIrSensor() {
print("Kızılötesi sensörü etkinleştirme işlemini burada gerçekleştirin.");
}
void turnOn() {
_illuminateDisplay();
_activateIrSensor();
}
// Diğer televizyon işlemleri buraya eklenebilir.
}
class SmartTelevision extends Television {
void _bootNetworkInterface() {
print("// Ağ arabirimini başlatma işlemini burada gerçekleştirin.");
}
void _initializeMemory() {
print("// Belleği başlatma işlemini burada gerçekleştirin.");
}
void _upgradeApps() {
print("// Uygulamaları güncelleme işlemini burada gerçekleştirin.");
}
@override
void turnOn() {
super.turnOn(); // Üst sınıfın turnOn metodunu çağır.
_bootNetworkInterface();
_initializeMemory();
_upgradeApps();
}
// Akıllı televizyon için diğer işlemler buraya eklenebilir.
}
void foo1() {
// Basit bir televizyon oluşturun
Television basicTv = Television();
print("Basic TV is turned on:");
basicTv.turnOn();
print("\n");
// Akıllı bir televizyon oluşturun
SmartTelevision smartTv = SmartTelevision();
print("Smart TV is turned on:");
smartTv.turnOn();
}
// Fonksiyon ezme
class Television2 {
// ···
set contrast(int value) {}
}
class SmartTelevision2 extends Television2 {
@override
set contrast(num value) {}
}
// Olmayan bir yontem çağrıldığı zaman otomatik olarak tanımlanan noSuchMethod metodunu çağırır.
class Person {
@override //overring noSuchMethod
noSuchMethod(Invocation invocation) =>
'Got the ${invocation.memberName} with arguments ${invocation.positionalArguments}';
}
// class Person {
// missing(int age, String name);
//
// @override //overriding noSuchMethod
// noSuchMethod(Invocation invocation) =>
// 'Got the ${invocation.memberName} with arguments ${invocation.positionalArguments}';
// }
void foo2() {
dynamic person =
new Person(); // person is declared dynamic hence staifies the first point
print(person.missing(
20, 'shubham')); //We are calling an unimplemented method called 'missing'
}
void main() {
foo2();
}