-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
101 lines (95 loc) · 2.53 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
console.log("-------------------------------")
console.log("Task-1");
console.log("-------------------------------")
class Movie{
constructor(title,studio,rating="PG"){
this.title=title;
this.studio=studio;
this.rating=rating;
}
get PG(){
return this.rating==="PG";
}
}
const obj5=new Movie("Kanaa","SK Studio","8.1");
console.log(obj5.title,obj5.rating,obj5.studio);
const obj1=new Movie("Casino Royale","Eon Productions","PG13");
console.log(obj1.title,obj1.studio,obj1.rating);
const obj2=new Movie("Om","BR Studio");
const obj3=new Movie("Hero","SK Studio");
const obj4=new Movie("Master","7Screen Studio");
let Arr=[obj1,obj2,obj3,obj4,obj5];
for(var i=0;i<Arr.length;i++){
if(Arr[i].PG===true)
console.log(`With Rating PG : ${Arr[i].title}`);
}
console.log("-------------------------------")
console.log("Task-2");
console.log("-------------------------------")
class Circle{
constructor(radius,color){
this.radius=radius;
this.color=color;
}
get Radius(){
return this.radius;
}
set Radius(r){
this.radius=r;
}
get Color(){
return this.color;
}
set Color(c){
this.color=c;
}
get toString(){
return `"Circle[radius=${this.radius},color=${this.color}]"`;
}
get Area(){
return Math.PI*Math.pow(this.radius,2);
}
get Circumference(){
return 2*Math.PI*this.radius;
}
}
const cir=new Circle(1.0,"red");
console.log(` ${cir.Radius},${cir.Color}
${cir.toString}
${cir.Area}
${cir.Circumference}`);
console.log("-------------------------------")
console.log("Task-3");
console.log("-------------------------------")
class Person{
constructor(name,age,address,gender,maritalstatus,contact,email){
this.name=name;
this.age=age;
this.address=address;
this.gender=gender;
this.maritalstatus=maritalstatus;
this.contact=contact;
this.email=email;
}
}
const per=new Person("Samy",24,"Panaimadal,Salem","Male","Single","9898989898","[email protected]");
console.log(per.name,per.age,per.address,per.gender,per.maritalstatus,per.contact,per.email);
console.log("-------------------------------")
console.log("Task-4");
console.log("-------------------------------")
class Uber{
constructor(price,km){
this.price=price;
this.km=km;
console.log("Price Per Km: "+this.price);
console.log("Number of Km: "+this.km);
}
set Rate(p){
this.price=p;
}
get Rate(){
return this.price*this.km;
}
}
const uber=new Uber(50,15);
console.log("Total Fare: "+uber.Rate);