-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhamza.js
72 lines (71 loc) · 1.66 KB
/
hamza.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
class Media {
constructor(title,isCheckedOut){
this._title = title;
this._isCheckedOut = isCheckedOut;
this._ratings = []
}
get title() {
return this._title ;
}
get isCheckedOut(){
return this._isCheckedOut;
}
get ratings(){
return this._ratings ;
}
set isCheckedOut(value){
this._isCheckedOut = value ;
}
getAverageRating () {
const sumOfRatings = this._ratings.reduce((acc , currval)=> {
acc + currval
})
const avreage = sumOfRatings / (this._ratings.length)
return avreage ;
}
toggleCheckOutStatus (value ){
this._isCheckedOut = !value
}
addRating(rating){
this._ratings.push(rating)
}
}
class Movie extends Media {
constructor (director,title,runTime,isCheckedOut) {
super(title,isCheckedOut);
this._director = director;
this._runTime = runTime ;
}
get director () {
return this._director ;
}
get runTime() {
return this._runTime
}
}
class Book extends Media {
constructor(author , title , pages , isCheckedOut){
super(title,isCheckedOut);
this._author = author ;
this._pages = pages
}
get author(){
return this._author ;
}
get pages () {
return this.pages ;
}
}
class CD extends Media {
constructor (artist, title , isCheckedOut , songs ) {
super(title,isCheckedOut);
this._artist = artist ;
this._songs = songs ;
}
get artist () {
return this._artist ;
}
get songs () {
return this._songs ;
}
}