From 77665d925457858e24dfb7d258d184a3be7c2023 Mon Sep 17 00:00:00 2001 From: Bastien Jacquelin Date: Mon, 6 Feb 2023 18:42:22 +0100 Subject: [PATCH] fix factory, bug in attributesRequiredFun in facory --- src/Console/main.js | 17 ++++++++--------- src/Model/Deck.js | 2 +- src/Model/Factory.js | 10 +++++++--- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/Console/main.js b/src/Console/main.js index 2374db8..2b9de4d 100644 --- a/src/Console/main.js +++ b/src/Console/main.js @@ -31,30 +31,29 @@ console.groupEnd(); console.group('Deck'); -let deck = new Deck([0,1,2,3]); +let deck = new Deck([0,1,3,4]); console.log(`All cards with 4 attributes size ${deck.allCards.length}`); console.log(`size output ${deck.outputCards.length}`); //Display all cards console.log(`All cards`); -console.log(deck.allCards) deck.allCards.forEach(e => { - console.log(e.color,e.number,e.shape,e.filling); + //console.log(e.color,e.number,e.shape,e.filling); + console.log(e.color,e.number,e.filling,e.outline); + //console.log(e.color,e.number,e.shape,e.outline); }); console.log(`Output cards`); // deck.outputCards.forEach(e => { // console.log(e.getAttributes()); // }); console.log(`set already made ${deck.setMade}`); - +console.log(`remaining cards:`); +deck.setMade.forEach(e => { + console.log(e.color,e.number,e.shape,e.filling); + }); let customCard=[new Card('red',1,'diamond','stripped')]; //deck.checkSet(customCard); -console.log(`deck size :${deck.allCards.length}`); -console.log(`remaining cars:`); -deck.setMade.forEach(e => { - console.log(e.color,e.number,e.shape,e.filling); - }); //let deck5 = new Deck([0,1,2,3,4]); //console.log(`All cards with 5 attributes size ${deck5.allCards.length}`); diff --git a/src/Model/Deck.js b/src/Model/Deck.js index 1c13a92..94df7a6 100644 --- a/src/Model/Deck.js +++ b/src/Model/Deck.js @@ -36,7 +36,7 @@ class Deck{ */ createCards(attributes){ let factory = new Factory(attributes) - return factory.concreteCardCreation(); + return factory.product } checkSet(selectedCards){ if(true){//isSet(selectedCards)){ diff --git a/src/Model/Factory.js b/src/Model/Factory.js index e85a853..7e57f18 100644 --- a/src/Model/Factory.js +++ b/src/Model/Factory.js @@ -4,6 +4,8 @@ class Factory{ this.product=this.concreteCardCreation(arrayOfAttributes,length); } attributesRequiredFun(arrayOfAttributes,length){ + console.log("arr attr") + console.log(arrayOfAttributes) let attributesRequiredTmp=[]; let nullArray=[0,0,0,0,0]; for(let i=0;i<5;i++){ @@ -18,6 +20,10 @@ class Factory{ attributesRequiredTmp.push(nullArray); } } + attributesRequiredTmp.forEach(e=>{ + console.log("tab index") + console.log(e); + }); return attributesRequiredTmp; } concreteCardCreation(arrayOfAttributes, length){ @@ -45,15 +51,13 @@ class Factory{ tabOfAllCards.push(new Card4WithoutNumber(attributes[0][n],attributes[2][s],attributes[3][f],attributes[4][o])); } else if(attributes[2][0]===0){ + console.log("jrentre la frro") tabOfAllCards.push(new Card4WithoutShape(attributes[0][n],attributes[1][s],attributes[3][f],attributes[4][o])); } else if(attributes[3][0]===0){ - console.log(attributes[0][n],attributes[1][s],attributes[2][f],attributes[4][o]); tabOfAllCards.push(new Card4WithoutFilling(attributes[0][n],attributes[1][s],attributes[2][f],attributes[4][o])); } else if(attributes[4][0]===0){ - console.log('rentre la'); - console.log(attributes[0][n],attributes[1][s],attributes[2][f],attributes[3][o]); tabOfAllCards.push(new Card4WithoutOutline(attributes[0][n],attributes[1][s],attributes[2][f],attributes[3][o])); } }