Skip to content

Commit

Permalink
Make dollar amount private
Browse files Browse the repository at this point in the history
  • Loading branch information
kaiosilveira authored Sep 28, 2022
2 parents d15dc5f + 72a1a63 commit de59dc4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ describe('Multi currency money', () => {
it('should multiply $5 by 2 and get $10', () => {
const five = new Dollar(5);
const product = five.times(2);
expect(product.amount).toEqual(10);
expect(product.equals(new Dollar(10))).toBe(true);
});

it('should preserve the initial dollar amount when multiplying multiple times', () => {
const five = new Dollar(5);
let product: Dollar = five.times(2);
expect(product.amount).toEqual(10);
expect(product.equals(new Dollar(10))).toBe(true);
product = five.times(3);
expect(product.amount).toEqual(15);
expect(product.equals(new Dollar(15))).toBe(true);
});
});

Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export default class Dollar {
amount: number;
private amount: number;

constructor(amount: number) {
this.amount = amount;
Expand Down

0 comments on commit de59dc4

Please sign in to comment.