diff --git a/apps/katapotter/src/app/game.spec.ts b/apps/katapotter/src/app/game.spec.ts index 96e543f..f28f554 100644 --- a/apps/katapotter/src/app/game.spec.ts +++ b/apps/katapotter/src/app/game.spec.ts @@ -1,16 +1,23 @@ import { Game } from './game'; describe('Game', () => { + let game : Game; + beforeEach(() => { + game = new Game(); + }); + + it('should create an instance', () => { + expect(game).toBeTruthy(); + }); test('buy one', () => { - const game = new Game(); - game.buy(1); + game.buy("p1", 1); expect(game.price).toBe(100); }); test('buy two', () => { - const game = new Game(); - game.buy(2); + game.buy("p1", 1); + game.buy("p2", 1); expect(game.price).toBe(190); }); }); diff --git a/apps/katapotter/src/app/game.ts b/apps/katapotter/src/app/game.ts index f0fe02b..ac5d108 100644 --- a/apps/katapotter/src/app/game.ts +++ b/apps/katapotter/src/app/game.ts @@ -1,6 +1,44 @@ export class Game { - buy(pins: number){} + // private _price = 0; + private booksvector: bookinfo[] = []; + private discount: number[] = [1, 0.95, 0.9, 0.8, 0.75]; + + buy(bookname: string, num: number){ + let flag = false; + for( let i=0;i