-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMaster.js
More file actions
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 **//
class CoffeeMachine {
start (){
// call DB
//filter value
return `starting the machine...`
}
brewCoffee (){
//complex Calculation
return `brewing coffee..`
}
pressstartbutton () {
let msgone = this.start()
let msgtwo = this.brewCoffee()
return `${msgone} + ${msgtwo}`
}
}
let myMachine = new CoffeeMachine();
//console.log(myMachine.start());
//console.log(myMachine.brewCoffee());
console.log(myMachine.pressstartbutton());
// **POLYMORPHISM** //
class Bird {
fly (){
return `Birds can fly...`
}
}
class Penguin{
fly(){
return `Penguin can't fly...`
}
}
let bird = new Bird()
let penguin = new Penguin()
console.log(bird.fly());
console.log(penguin.fly());
//**STATIC METHOD **//
class Calculator {
static add (a,b){
return a+b;
}
}
console.log(Calculator.add(2,3));
//let minicalc = new Calculator()
//console.log(minicalc.add(2,3));