From 0add9526fe5fc2450a2dbcd5e4cb95bd82db2d02 Mon Sep 17 00:00:00 2001 From: Bastien Jacquelin Date: Thu, 2 Feb 2023 15:16:23 +0100 Subject: [PATCH] remove from deck set cards --- src/Console/main.js | 19 +++++++++++++++---- src/Model/Card.js | 3 +++ src/Model/Card5.js | 3 +++ src/Model/Deck.js | 30 ++++++++++++++++-------------- src/Model/unfoundCardException.js | 4 ++-- 5 files changed, 39 insertions(+), 20 deletions(-) diff --git a/src/Console/main.js b/src/Console/main.js index 930cf2c..a349a7b 100644 --- a/src/Console/main.js +++ b/src/Console/main.js @@ -41,10 +41,19 @@ deck.outputCards.forEach(e => { }); console.log(`set already made ${deck.setMade}`); - - - - +deck.allCards.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}`); +deck.allCards.forEach(e => { + console.log(e.color,e.number,e.shape,e.filling); +}); +console.log(`remaining cars:`); +deck.setMade.forEach(e => { + console.log(e.color,e.number,e.shape,e.filling); + }); let deck5 = new Deck(5) console.log(`All cards with 5 attributes size ${deck5.allCards.length}`); @@ -56,4 +65,6 @@ console.log(`All cards with 5 attributes size ${deck5.allCards.length}`); + + console.groupEnd(); diff --git a/src/Model/Card.js b/src/Model/Card.js index d7da58b..0b8997b 100644 --- a/src/Model/Card.js +++ b/src/Model/Card.js @@ -29,5 +29,8 @@ class Card{ getAttributes(){ return [this.color,this.number,this.shape,this.filling]; } + equals(card){ + return this.color===card.color && this.number===card.number && this.shape===card.shape && this.filling===card.filling; + } }//export {Card} \ No newline at end of file diff --git a/src/Model/Card5.js b/src/Model/Card5.js index b9d7894..bead780 100644 --- a/src/Model/Card5.js +++ b/src/Model/Card5.js @@ -21,5 +21,8 @@ class Card5 extends Card { // return [this.color,this.number,this.shape,this.filling,this.outline]; return super.getAttributes().concat(this.outline); } + equals(card){ + return this.color===card.color && this.number===card.number && this.shape===card.shape && this.filling===card.filling && this.outline===card.outline ; + } } // export {Card5}; \ No newline at end of file diff --git a/src/Model/Deck.js b/src/Model/Deck.js index 81ee4e8..5be6949 100644 --- a/src/Model/Deck.js +++ b/src/Model/Deck.js @@ -4,7 +4,7 @@ class Deck{ this.remainingCards=this.allCards;// cards in the stack this.outputCards=[];// 12 cards lay on the table this.setMade=[];// array with all the set already mades (array of set) - this.createDeck(); + //this.createDeck(); } createDeck(){ for (let i=0; i<12; i++){ @@ -24,9 +24,9 @@ class Deck{ */ createCards(nbAttributes){ const tabColor = ['red','purple','green','blue','orange']; - const tabShape = ['diamond','oval','wave','star','circle'] - const tabFilling = ['empty','stripped','full','pointed','squared']; const tabNumber = [1,2,3,4,5]; + const tabShape = ['diamond','oval','wave','star','circle']; + const tabFilling = ['empty','stripped','full','pointed','squared']; const tabOutline = ['full','dotted ','aa','bb','cc']; let tabOfAllCards=[]; for (let c=0; c