-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscript13.js
139 lines (95 loc) · 2.39 KB
/
script13.js
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
// POM -- framework
// Design pattern
// User defined data type ???
// Class
// 1)Encapsulation 2) Inheritance 3) Polymorphism 4) Abstraction
// Encapsulation
// Inheritance
// Polymmorphsim - overloading overriding
// overloading --- same class , same method name different signature \
// overriding -- different class same method name and same signature
// Oops
// Class defined
// Data type -----> string , boolean , array , number , object , map , set dom
// User defined data ------> class defined --------objects
// Objects ------> properties and methods
// Oops
//1)Encapsulation
//2)Inhertitance
//3)Polymorphism
//4)Abstraction
// program 1
// class Student {
// constructor(fn,ln){
// this.firstName = fn
// this.lastName = ln
// }
// displayName(){
// console.log(this.firstName + this.lastName)
// }
// }
// let amol = new Student("chinmay","deshpande")
// console.log(amol.firstName)
// console.log(amol.lastName)
// program 2
// class Teacher {
// constructor(fn,ln){
// this.firstName = fn
// this.lastName = ln
// }
// displayName(){
// console.log(this.firstName+ this.lastName)
// }
// }
// class Student extends Teacher {
// constructor(fn,ln,spec){
// super(fn,ln)
// self.specialization = spec
// }
// displaySpec(){
// console.log(this.specialization)
// }
// }
// let amol = new Student("amol","rao","salary")
// amol.displayName()
// amol.displaySpec()
// console.log(amol.firstName)
// console.log(amol.lastName)
// polymorphism
// class Calculator {
// addition(a,b,c,d){
// if(a != undefined && b != undefined && c != undefined && d != undefined){
// console.log(a+b+c+d)
// }
// else if(a != undefined && b != undefined && c != undefined){
// console.log(a+b+c)
// }
// else if(a != undefined && b != undefined){
// console.log(a+b)
// }
// }
// }
// let cal = new Calculator()
// cal.add(12,4)
// cal.add(12,4,3)
// cal.add(12,4,3,3)
// program 4
// overriding
class WorldBank {
save(){
console.log("save")
}
loan(){
console.log("loan")
}
}
class SBI extends WorldBank{
save(){
console.log("save SBI")
}
loan(){
console.log("loan SBI")
}
}
let SBI = new WorldBank()
SBI.loan()