Skip to content

Commit

Permalink
pull up .times operation to Money class
Browse files Browse the repository at this point in the history
Tasklist:
- $5 + 10CHF = $10 if rate is 2:1 🎯
- $5 * 2 = $10 βœ…
- Make "amount" private βœ…
- Dollar side-effects? βœ…
- Money rounding?
- equals() βœ…
- Equal null
- Equal object
- 5 CHF * 2 = 10 CHF βœ…
- Dollar/Franc duplication
- Common `.equals` βœ…
- Common `.times` πŸ‘ˆπŸΌ
- Compare Francs with Dollars βœ…
- Currency? βœ…
- Merge multiplication tests?
  • Loading branch information
kaiosilveira committed Sep 29, 2022
1 parent 0d89759 commit 6fbce94
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions src/money/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,16 @@ class Money {
}

times(multiplier: number): Money {
return new Money(0, 'USD');
return new Money(this.amount * multiplier, this.currency);
}

get currency(): string {
return this._currency;
}
}

export class Dollar extends Money {
times(multiplier: number): Money {
return new Money(this.amount * multiplier, this.currency);
}
}
export class Dollar extends Money {}

export class Franc extends Money {
times(multiplier: number): Money {
return new Money(this.amount * multiplier, this.currency);
}
}
export class Franc extends Money {}

export default Money;

0 comments on commit 6fbce94

Please sign in to comment.