Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@ TODO


## Resources
https://www.sohamkamani.com/javascript/enums/
### JavaScript enumeration
https://www.sohamkamani.com/javascript/enums/
https://dmitripavlutin.com/javascript-enum/#comments
https://stackoverflow.com/questions/43000451/javascript-es6-enums-inside-classes-used-outside-like-a-static-enum
https://2ality.com/2020/01/enum-pattern.html
12 changes: 8 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
// Node modules
const inquirer = require("inquirer");
const path = require("path");
const fs = require("fs");

// Classes
const Employee = require("./lib/Employee");
const Manager = require("./lib/Manager");
const Engineer = require("./lib/Engineer");
const Intern = require("./lib/Intern");

// Node modules
const inquirer = require("inquirer");
const path = require("path");
const fs = require("fs");
// Enumerations
const EmployeeTypeEnum = require("./lib/EmployeeTypeEnum");

const OUTPUT_DIR = path.resolve(__dirname, "output");
const outputPath = path.join(OUTPUT_DIR, "team.html");
Expand Down
5 changes: 4 additions & 1 deletion lib/Employee.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
const EmployeeTypeEnum = require("./EmployeeTypeEnum");

class Employee {
constructor(name, id, email) {
this.name = name;
this.id = id;
this.email = email;
this.role = EmployeeTypeEnum.employee;
}

getName() {
Expand All @@ -18,7 +21,7 @@ class Employee {
}

getRole() {
return "Employee";
return this.role.toString();
}
}

Expand Down
16 changes: 16 additions & 0 deletions lib/EmployeeTypeEnum.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class EmployeeTypeEnum {
static employee = new EmployeeTypeEnum("Employee");
static manager = new EmployeeTypeEnum("Manager");
static engineer = new EmployeeTypeEnum("Engineer");
static intern = new EmployeeTypeEnum("Intern");

constructor(name) {
this.name = name;
}

toString() {
return `EmployeeTypeEnum.${this.name}`;
}
}

module.exports = EmployeeTypeEnum;
4 changes: 3 additions & 1 deletion lib/Engineer.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
const EmployeeTypeEnum = require("./EmployeeTypeEnum");
const Employee = require("./Employee");

class Engineer extends Employee {
constructor(name, id, email, github) {
super(name, id, email);
this.github = github;
this.role = EmployeeTypeEnum.engineer;
}

getGithub() {
return this.github;
}

getRole() {
return "Engineer";
return this.role.toString();
}
}

Expand Down
4 changes: 3 additions & 1 deletion lib/Intern.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
const EmployeeTypeEnum = require("./EmployeeTypeEnum");
const Employee = require("./Employee");

class Intern extends Employee {
constructor(name, id, email, school) {
super(name, id, email);
this.school = school;
this.role = EmployeeTypeEnum.intern;
}

getSchool() {
return this.school;
}

getRole() {
return "Intern";
return this.role.toString();
}
}

Expand Down
4 changes: 3 additions & 1 deletion lib/Manager.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
const EmployeeTypeEnum = require("./EmployeeTypeEnum");
const Employee = require("./Employee");

class Manager extends Employee {
constructor(name, id, email, officeNumber) {
super(name, id, email);
this.officeNumber = officeNumber;
this.role = EmployeeTypeEnum.manager;
}

getOfficeNumber() {
return this.officeNumber;
}

getRole() {
return "Manager";
return this.role.toString();
}
}

Expand Down