February 2019
Beginner
694 pages
18h 4m
English
To simplify our code, we will create an abstract base class to hold all code that is common to infants, children, and adults. Again, abstract classes can never be instantiated, and, as such, are designed to be derived from. We will call this class Person, as follows:
abstract class Person implements IPerson { Category: PersonCategory; private DateOfBirth: Date; constructor(dateOfBirth: Date) { this.DateOfBirth = dateOfBirth; this.Category = PersonCategory.Undefined; } abstract canSignContracts(): boolean printDetails() : void { console.log(`Person : `); console.log(`Date of Birth : ` + `${this.DateOfBirth.toDateString()}`); console.log(`Category : ` + `${PersonCategory[this.Category]}`); console.log(`Can sign : ` + `${this.canSignContracts()}`); ...Read now
Unlock full access