-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproxy.js
More file actions
50 lines (42 loc) · 692 Bytes
/
proxy.js
File metadata and controls
50 lines (42 loc) · 692 Bytes
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
class CarAccess
{
open()
{
console.log('Opening car door');
}
close()
{
console.log('Closing the car door');
}
}
class SecuritySystem
{
constructor(door)
{
this.door = door;
}
open(password)
{
if(this.authenticate(password))
{
this.door.open();
}
else
{
console.log('Access denied!');
}
}
authenticate(password)
{
return password == 'Ilon';
}
close()
{
this.door.close();
}
}
//test
const door = new SecuritySystem(new CarAccess());
door.open('Jack');
door.open('Ilon');
door.close();