-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
134 lines (94 loc) · 2.69 KB
/
script.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
124
125
126
127
128
129
130
131
console.log("hi")
//Task 1
class Movie{
constructor(title,studio,rating="10"){
this.title=title;
this.studio=studio;
this.rating=rating;
}
set rating(n){
console.log ("set the rating value"+" "+n)
this._rating=n;
}
get rating(){
return this._rating;
}
}
//const film2=new Movie("jailer","sunpictures","PG15")
/*B) The constructor for the class Movie will set the class property rating
to "PG" as default when no rating is provided.*/
const film1=new Movie("Casino Royale","Eon Productions");
console.log(film1.title);
console.log(film1.studio);
console.log(film1.rating);
/* D) Write a piece of code that creates an instance of the class Movie
// with the title “Casino Royale”, the studio “Eon Productions”, and the rating “PG13”*/
const film=new Movie("Casino Royale","Eon Productions","PG13");
console.log(film.title);
console.log(film.studio);
console.log(film.rating);
/**************************************************************************************************************************/
//QA 2
class Circle{
constructor(radius,color){
this.radius=radius;
this.color=color;
}
set setRadius(radius){
this.radius=radius;
}
get getRadius(){
return this.radius;
}
set setColor(color){
this.color=color;
}
get getColor(){
return this.color;
}
get toString(){
return `"Circle[circle=${this.radius},color=${this.color}]"`;
}
get area(){
return Math.PI*this.radius*this.radius;
}
get circumference(){
return 2*Math.PI*this.radius;
}
}
const circle=new Circle("1.0","red");
console.log(circle.getRadius);
console.log(circle.getColor);
console.log(circle.toString);
console.log(circle.area);
console.log(circle.circumference);
/****************************************************************************************************/
//QA 3
class Person{
constructor(name,age,gender,salary){
this.names=name;
this.age=age;
this.gender=gender;
this.salary=salary;
}
}
let obj1=new Person("sathish","32","male","55k");
console.log(obj1.names);
console.log(obj1.age);
console.log(obj1.gender);
console.log(obj1.salary);
/******************************************************************************************************/
//QA4
class Uber{
constructor(km,ruba=50){
this.km=km;
this.ruba=ruba;
}
get price(){
return this.ruba=this.km*this.ruba;
}
}
const uber1=new Uber(5);
const uber2=new Uber(5,125);
console.log(uber1.price);
console.log(uber2.price);