Skip to content

Commit

Permalink
Format code A.
Browse files Browse the repository at this point in the history
  • Loading branch information
codecop committed Dec 7, 2023
1 parent 9914d90 commit 8172c16
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 17 deletions.
2 changes: 2 additions & 0 deletions TypeScript/app/a/Assignment.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ our online shop. The main logic is in `Discount`.
* Bring `Discount` under test. Make sure to cover all paths in the core logic.
* There is an existing `DiscountTest` with a first test case which might or might not work.
* You cannot change `MarketingCampaign` because it is used by other teams as well.

(This is a copied document - do not edit!)
6 changes: 3 additions & 3 deletions TypeScript/app/a/discount.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {Money} from "./money";
import {MarketingCampaign} from "./marketing-campaign";
import { Money } from "./money";
import { MarketingCampaign } from "./marketing-campaign";

export class Discount {

marketingCampaign: MarketingCampaign;
private marketingCampaign: MarketingCampaign;

constructor() {
this.marketingCampaign = new MarketingCampaign();
Expand Down
6 changes: 2 additions & 4 deletions TypeScript/app/a/marketing-campaign.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
export class MarketingCampaign {

public isActive(): boolean {
let now: Date = new Date();
return now.getMilliseconds() % 2 == 0;
return new Date().getMilliseconds() % 2 == 0;
}

public isCrazySalesDay(): boolean {
let now: Date = new Date();
return now.getDay() === 5;
return new Date().getDay() === 5; // Friday corresponds to day number 5
}

}
1 change: 0 additions & 1 deletion TypeScript/app/a/money.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export class Money {
}

reduceBy(p: number): Money {
// value.multiply(new BigDecimal(100 - p)).divide(new BigDecimal(100))
return new Money((this.value * (100 - p) / 100).toFixed(2));
}

Expand Down
18 changes: 9 additions & 9 deletions TypeScript/test/a/discount.test.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import {Discount} from "../../app/a/discount";
import {Money} from "../../app/a/money";
import {expect} from "chai";
import { Discount } from "../../app/a/discount";
import { Money } from "../../app/a/money";
import { expect } from "chai";

describe('Discount Test', () => {
describe('Discount', () => {

it('test in a', () => {
let discount = new Discount();
it('test 1', () => {
const discount = new Discount();

let net = new Money(1002);
let total = discount.discountFor(net);
const net = new Money(1002);
const total = discount.discountFor(net);

expect(total.value).to.be.equal(901.8);
});

});
});

0 comments on commit 8172c16

Please sign in to comment.