- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMaster.js
More file actions
Latest commit
51 lines (45 loc) · 991 Bytes
/
Copy pathMaster.js
File metadata and controls
51 lines (45 loc) · 991 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
//** ABSTRACTION **//
classCoffeeMachine{
start(){
// call DB
//filter value
return`starting the machine...`
}
brewCoffee(){
//complex Calculation
return`brewing coffee..`
}
pressstartbutton(){
letmsgone=this.start()
letmsgtwo=this.brewCoffee()
return`${msgone} + ${msgtwo}`
}
}
letmyMachine=newCoffeeMachine();
//console.log(myMachine.start());
//console.log(myMachine.brewCoffee());
console.log(myMachine.pressstartbutton());
// **POLYMORPHISM** //
classBird{
fly(){
return`Birds can fly...`
}
}
classPenguin{
fly(){
return`Penguin can't fly...`
}
}
letbird=newBird()
letpenguin=newPenguin()
console.log(bird.fly());
console.log(penguin.fly());
//**STATIC METHOD **//
classCalculator{
staticadd(a,b){
returna+b;
}
}
console.log(Calculator.add(2,3));
//let minicalc = new Calculator()
//console.log(minicalc.add(2,3));