Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >> generic-product <<
- import { Validator } from '../common/validators';
- import { GenderType } from "../common/gender-type";
- export abstract class Product {
- protected _price: number;
- protected _name: string;
- protected _brand: string;
- protected _gender: GenderType;
- public constructor(name: string, brand: string, price: number, gender: GenderType) {
- Validator.validateObject(name);
- Validator.validatePrice(price);
- this._name = name;
- this._brand = brand;
- this._price = price;
- this._gender = gender;
- }
- public get name(): string {
- return this.name;
- }
- public get price(): number {
- return this.price;
- }
- public get brand(): string {
- return this.brand;
- }
- public get gender(): GenderType {
- return this.gender;
- }
- public print(): string {
- return `#${this.name} ${this.brand}\r\n #Price: \$${this.price}\r\n #Gender: ${GenderType[this.gender]}\r\n`;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment