alboig

shampoo-cosmetics

Jun 10th, 2020
378
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { isFloat, isLength } from 'validator';
  2. import { GenderType } from '../common/gender-type';
  3. import { IShampoo } from '../../common/contracts/shampoo';
  4. import { UsageType } from './../common/usage-type'
  5. import { Product } from './generic-product';
  6.  
  7. export class Shampoo extends Product implements IShampoo{
  8.   private _milliliters: number;
  9.   private _usage: UsageType;
  10.   private readonly minNameLength: number = 3;
  11.   private readonly maxNameLength: number = 10;
  12.   private readonly minBrandLength: number = 2;
  13.   private readonly maxBrandLength: number = 10;
  14.   private readonly minPrice: number = 0;
  15.  
  16.   public constructor(name: string, brand: string, price: number, gender: GenderType, milliliters: number, usage: UsageType) {
  17.     super(name, brand, price, gender);
  18.     this._milliliters = milliliters;
  19.     this._usage = usage;
  20.   }
  21.  
  22.   public get milliliters(): number {
  23.     return this._milliliters;
  24.   }
  25.  
  26.   public get usage(): UsageType {
  27.     return this._usage;
  28.   }
  29.  
  30.   // Think about how to extend the print method ---> better method
  31.   public print(): string {
  32.     return super.print() + `#Milliliters: ${this.milliliters}\r\n #Usage: ${UsageType[this.usage]}\r\n ===`;
  33.     // tslint:disable-next-line:max-line-length
  34.   }
  35. }
Add Comment
Please, Sign In to add comment