-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinheritance.js
More file actions
38 lines (37 loc) Β· 872 Bytes
/
inheritance.js
File metadata and controls
38 lines (37 loc) Β· 872 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
// Hazrat Ali
// University Of Scholars
class SmartDevice{
constructor(name, price){
this.name = name;
this.price = price;
}
charging(){
console.log('I am eating electrons...they yummy')
}
}
class Phone extends SmartDevice{
constructor(name, price, camera){
super(name, price);
this.camera = camera;
}
sendSMS(){
console.log('I am sending text to my gf/bf')
}
}
// inheritance
class Watch extends SmartDevice{
constructor(name, price, distance){
super(name, price);
this.distance = distance;
}
}
class Tablet extends SmartDevice{
constructor(name, price, isWifi){
super(name, price);
this.isWifi = isWifi;
}
}
const samsu = new Phone('Samsung', 60000, '16GB')
samsu.sendSMS()
const ipad = new Tablet('Apple', 45000, true)
//ipad.sendSMS()