Skip to content

Commit

Permalink
Add Dollar class with the capability of being multiplied by scalars
Browse files Browse the repository at this point in the history
  • Loading branch information
kaiosilveira authored Sep 28, 2022
2 parents cfe99a6 + 03bce04 commit b152e54
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/index.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Dollar from '.';

describe('Multi currency money', () => {
it.todo('should sum $5 + 10CHF as being $10 if exchange rate is 2:1');

describe('multiplication', () => {
it('should multiply $5 by 2 and get $10', () => {
const five = new Dollar(5);
five.times(2);
expect(five.amount).toEqual(10);
});
});
});
12 changes: 11 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
console.log('Hello world!');
export default class Dollar {
amount: number;

constructor(amount: number) {
this.amount = amount;
}

times(multiplier: number) {
this.amount *= multiplier;
}
}

0 comments on commit b152e54

Please sign in to comment.