File tree Expand file tree Collapse file tree
typescript/src/world-company-remuneration Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,20 +9,32 @@ export class BasketInformations {
99 // The product of the basket
1010 static map : Map < string , number > = new Map < string , number > ( )
1111
12- addProductToBasket ( product : string , price : number ) {
13- BasketInformations . map . set ( product , price )
12+ // The fact that the basket has promo code
13+ static codeDePromotion : boolean = false
14+
15+
16+ addProductToBasket ( product : string , price : number , promoCode : boolean = false ) {
17+ if ( promoCode ) {
18+ BasketInformations . codeDePromotion = true
19+ } else {
20+ BasketInformations . map . set ( product , price )
21+ }
1422 }
1523
1624 getBasketPrice ( inCents : boolean ) : Number {
1725 var v = 0 ;
1826 for ( let s of Array . from ( BasketInformations . map . values ( ) ) ) {
1927 v += s ;
2028 }
29+ if ( BasketInformations . codeDePromotion ) {
30+ v -= 100 ;
31+ }
2132 return inCents ? new Number ( v * 100 ) : Number ( v )
2233 }
2334
2435 resetBasket ( ) {
2536 this . buyBasket ( ) ;
37+ BasketInformations . codeDePromotion = false ;
2638 }
2739
2840 buyBasket ( ) {
You can’t perform that action at this time.
0 commit comments