-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOOPS.html
More file actions
40 lines (37 loc) · 1.17 KB
/
Copy pathOOPS.html
File metadata and controls
40 lines (37 loc) · 1.17 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>OOPs in HTML</title>
</head>
<body>
<script>
class Employee{
#id;
#name;
#salary;
//constructor - intialise object properties
constructor(id,name,salary){
this.id = id;
this.name = name;
this.salary = salary;
}
displayDetails(){
document.write("<br> ***************************** ");
document.write("<br>Employee ID : "+this.id);
document.write("<br>Employee Name : "+this.name);
this.salary =this.salary+(this.salary*.10);
document.write("<br>Employee Salary : "+this.salary);}
}
//define objects
var e1 = new Employee(101,"Martin Roy",5000); //invokes constructor
var e2 = new Employee(102,"Jhon Doe",6000);
var e3 = new Employee(103,"Duke William",10000);
//invokes methods of class
e1.displayDetails();
e2.displayDetails();
e3.displayDetails();
</script>
</body>
</html>