class Discount {isPercentage: booleanamount: numberconstructor(isPercentage: boolean,amount: number) {this.isPercentage = isPercentagethis.amount = amount}apply(article: Article) {if (this.isPercentage) {article.price = article.price - (article.price * this.amount)} else {article.price = article.price - this.amount}}}const discount: Discount = new Discount(false, 10)discount.apply({price: 39,vat: 0.2,title: 'Form Design Patterns'})
