-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
44 lines (42 loc) · 1.05 KB
/
main.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
/*
Start of User Class
*/
function User(email, username) { // User Constractor
this.email = email;
this.username = username;
this.isOnline = false;
this.isDisable = false;
}
User.prototype.login = function(password){
this.isOnline = true;
console.log(this.username + ' has logged in.');
}
User.prototype.logout = function(){
this.isOnline = false;
console.log(this.username + ' has logged out.');
}
/*
End of User Class
*/
var user = new User('[email protected]', 'user');
console.log(user);
/*
Start of Admin Class
*/
function Admin(email, username){ // Admin Constractor
User.call(this, email, username);
}
Admin.prototype = Object.create(User.prototype);
Admin.prototype.disableUser = function(user){
user.isDisable = true;
console.log(this.username + ' has disabled: ' + user.username);
}
Admin.prototype.enableUser = function(user){
user.isDisable = false;
console.log(this.username + ' has enabled: ' + user.username);
}
/*
End of Admin Class
*/
var admin = new Admin('[email protected]', 'admin');
console.log(admin);