-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path4-pricing.js
More file actions
39 lines (32 loc) · 786 Bytes
/
Copy path4-pricing.js
File metadata and controls
39 lines (32 loc) · 786 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/* eslint-disable */
import Currency from './3-currency';
export default class Pricing {
constructor(amount, currency) {
this._amount = amount;
this._currency = currency;
}
get amount() {
return this._amount;
}
set amount(amount) {
if (typeof amount !== 'number') {
throw TypeError('amount must be a Number');
}
this._amount = amount;
}
get currency() {
return this._currency;
}
set currency(currency) {
if (!(currency instanceof Currency)) {
throw TypeError('currency must be a Currency');
}
this._currency = currency;
}
displayFullPrice() {
return `${this.amount} ${this.currency.displayFullCurrency()}`;
}
static convertPrice(amount, conversionRate) {
return amount * conversionRate;
}
}