-
Notifications
You must be signed in to change notification settings - Fork 14
/
app.js
28 lines (24 loc) · 1.04 KB
/
app.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
const EmployeeFactory = require('./EmployeeFactory');
const DepartmentFactory = require('./DepartmentFactory');
const FactoryProvider = require('./FactoryProvider');
/*var list = [];
var employeeFactory = new EmployeeFactory();
var departFactory = new DepartmentFactory();
list.push(employeeFactory.create("Alex", 10));
list.push(employeeFactory.create("Tim", 20));
list.push(departFactory.create("Admin", 30));
list.push(departFactory.create("HR", 40));
for (var i = 0, len = list.length; i < len; i++) {
console.log(list[i].getName());
console.log(list[i].getId());
} */
var provider = new FactoryProvider();
var factory = provider.getFactory("Employee");
var emp = factory.create("Alex", 10);
console.log("Printing Employee details");
console.log(" Employee ID : " + emp.getId() + " Employee Name: " + emp.getName());
console.log("\n");
console.log("Printing Department details");
factory = provider.getFactory("Department");
var dept = factory.create("HR", 20);
console.log(" Department ID : " + dept.getId() + " Department Name: " + dept.getName());