-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest2.js
More file actions
123 lines (104 loc) · 2.97 KB
/
Copy pathtest2.js
File metadata and controls
123 lines (104 loc) · 2.97 KB
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
// class Computer {
// constructor(brand, price, rating){
// this.brand = brand;
// this.price = price;
// this.rating = rating;
// }
// static someInfoComp() {
// console.log("This is some info about Computer class");
// }
// setBrand(name){
// this.brand = name;
// }
// getBrand(){
// console.log("The name of the brand is " + this.brand);
// }
// setPrice(price) {
// this.price = price;
// }
// getPrice() {
// console.log("The price is " + this.price);
// }
// setRating(rate){
// this.rating = rate;
// }
// getRating(){
// console.log("The rate is " + this.rating);
// }
// specialMethod(){
// return "This is a special method of the Computer class";
// }
// }
// // Creating a child class of Computer:
// class CompInfo extends Computer {
// constructor(brand, price, rating, ram) {
// super(brand, price, rating);
// this.ram = ram;
// }
// static someInfoCompNew(){
// console.log("This is some info about CompInfo class");
// }
// setRam(ramValue){
// this.ram = ramValue;
// }
// getRam() {
// console.log("The ram of the computer is " + this.ram + "GB");
// }
// callingParentMethod(){
// return super.specialMethod();
// }
// }
// // Creating and using an object of Computer class:
// const obj1 = new Computer("", 0, 0);
// obj1.setBrand("My Brand");
// obj1.getBrand()
// obj1.setPrice(55000);
// obj1.getPrice();
// obj1.setRating(4.8);
// obj1.getRating();
// // Creating and using an object of CompInfo class:
// const obj2 = new CompInfo("", 0, 0, 0);
// obj2.setBrand("ABC");
// obj2.setPrice(45000);
// obj2.setRating(4.4);
// obj2.setRam(4);
// obj2.getBrand();
// obj2.getPrice();
// obj2.getRating();
// obj2.getRam();
// // Calling the static methods:
// Computer.someInfoComp();
// CompInfo.someInfoComp();
// CompInfo.someInfoCompNew();
// // Calling the special method:
// console.log("😀😀😀😀😀")
// console.log(obj2.callingParentMethod())
// class First {
// constructor(a, b) {
// this.a = a;
// this.b = b;
// console.log("This is from the constructor class of First class");
// }
// sum(){
// return this.a + this.b;
// }
// division(){
// return this.a / this.b;
// }
// }
// class Second extends First {
// constructor(a, b) {
// super(a, b);
// console.log("This is from the constructor of the Second class")
// }
// gettingInfoOfFirstClass(){
// console.log(super.a);
// console.log(super.b);
// console.log(super.sum())
// console.log(super.division())
// }
// }
// const firstObj = new First(10,5);
// const secondObj = new Second(20,4);
// console.log(firstObj.a, firstObj.b, firstObj.sum(), firstObj.division());
// console.log(secondObj.a, secondObj.b, secondObj.sum(), secondObj.division());