...

/

Implement the Class Hierarchy: Model Classes

Implement the Class Hierarchy: Model Classes

Let’s learn how to code the model classes to implement the class hierarchy.

The JS class model shown below can be directly coded to get the code of the model classesPerson, Employee, and Author as well as for the enumeration type EmployeeCategoryEL.

Define subtype relationships

We define the subtype relationships between Employee and Person, as well as between Author and Person, with extends. For instance, in src/m/Employee.js we define:

Press + to interact
EmployeeCategoryEL = new Enumeration(["Manager"]);
class Employee extends Person {
constructor({ personId, name, empNo, category, department }) {
super({ personId, name });
this.empNo = empNo;
if (category) this.category = category;
if (department) this.department = department;
}
...
}

Load the instances of the root class

...