February 2019
Beginner
694 pages
18h 4m
English
According to our requirements, the class instance that is returned by the Factory must be able to do two things—print the category of the person in the required format, and tell us whether they can sign contracts. Let's start by defining an enum and an interface to satisfy this requirement:
enum PersonCategory {
Infant,
Child,
Adult,
Undefined
}
interface IPerson {
Category: PersonCategory;
canSignContracts(): boolean;
printDetails();
}
We start with an enum to hold the valid values for a PersonCategory, that is, Infant, Child, Adult, or Undefined. The Undefined enum value is used to indicate that we have not categorized the Person as yet. We then define an interface named IPerson that holds all of the functionality ...
Read now
Unlock full access