-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathday14.js
89 lines (81 loc) · 1.96 KB
/
day14.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
class Person{
constructor(firstName,lastName,age){
this.firstName=firstName
this.lastName=lastName
this.age=age
}
greeting(){
console.log(`Hello! ${this.firstName}`)
}
updateAge(num1){
this.age+=num1;
}
static genericGreeting(){
console.log("Hello User")
}
get fullName(){
return this.firstName+" "+this.lastName
}
get firstName(){
return this._firstName;
}
set firstName(value){
this._firstName=value
}
get lastName(){
return this._lastName.toUpperCase();
}
set lastName(value){
this._lastName=value
}
}
const person1= new Person("Chandan","Sahoo",18)
person1.greeting()
person1.updateAge(1)
console.log(person1.age)
class Student extends Person{
static studentCount=0
constructor(firstName,lastName,age,id){
super(firstName,lastName,age)
this.studentID=id
this.incrementStudent()
}
incrementStudent(){
Student.studentCount++
}
greeting(){
console.log(`Hello ${this.name} hehe`)
}
static totalStudent(){
console.log(`Total Student : ${Student.studentCount}`)
}
}
const student1 = new Student("Chandan","Sahoo",18,123456)
console.log(student1.fullName)
console.log(student1.studentID)
console.log(student1.firstName)
student1.greeting()
const student2= new Student("Batman","WC",18,23456)
const student3= new Student("Superman","WC",18,23457)
Person.genericGreeting()
Student.totalStudent()
class Bank{
#name
#balance=0
constructor(name,balance1,balance2) {
this.#name=name
this.depositBalance(balance1)
this.creditBalance(balance2)
}
depositBalance(balance){
this.#balance+=balance
}
creditBalance(balance){
this.#balance-=balance
}
showBalance(balance){
return this.#balance
}
}
const pickie1= new Bank("Chandan",45000000,2)
console.log(pickie1.showBalance())