November 2019
Beginner
804 pages
20h 1m
English
First of all, let's define our Genre enum. We'll use a string enum since this will be the easiest to understand:
enum Genre {
Horror = "Horror",
Fantastic = "Fantastic",
Thriller = "Thriller",
Romance = "Romance",
Fiction = "Fiction"
}
Next, we can implement the base Media class:
abstract class Media {
private _identifier: string;
protected constructor(
private _name: string,
private _description: string,
private _pictureLocation: string,
private _genre: Genre,
identifier?: string,
) {
if (identifier) {
this._identifier = identifier;
} else {
// this is just for the example; for any real project, use
// UUIDs instead: https://www.npmjs.com/package/uuid
this._identifier = Math.random().toString(36). substr(2,9); ...Read now
Unlock full access