diff --git a/src/Console/Console.html b/src/Console/Console.html index 1f6b5c3..f639d2a 100644 --- a/src/Console/Console.html +++ b/src/Console/Console.html @@ -17,6 +17,7 @@ + diff --git a/src/Console/main.js b/src/Console/main.js index a349a7b..b0652e6 100644 --- a/src/Console/main.js +++ b/src/Console/main.js @@ -27,11 +27,11 @@ try { } console.groupEnd(); console.group('Deck'); -let deck = new Deck(4); +let deck = new Deck([0,1,2,3],4); console.log(`All cards with 4 attributes size ${deck.allCards.length}`); -console.log(`size ${deck.outputCards.length}`); - +console.log(`size output ${deck.outputCards.length}`); +// Display all cards // deck.allCards.forEach(e => { // console.log(e.color,e.number,e.shape,e.filling); // }); @@ -41,30 +41,22 @@ 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); +//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}`); +//let deck5 = new Deck([0,1,2,3,4]); +//console.log(`All cards with 5 attributes size ${deck5.allCards.length}`); // deck5.allCards.forEach(e => { // console.log(e.color,e.number,e.shape,e.filling,e.outline); // }); //console.log(`Remaining cards ${deck.remainingCards}`); //console.log(`random : ${deck.getRandCard()}`); - - - - console.groupEnd(); diff --git a/src/Model/Card.js b/src/Model/Card.js index 0b8997b..3ee1a44 100644 --- a/src/Model/Card.js +++ b/src/Model/Card.js @@ -1,21 +1,25 @@ class Card{ - constructor(color, number, shape, filling){ - if(!color){ + constructor(color, number, shape, filling, outline){ + if(color=''){ throw new EmptyParamaterException('Color'); } - if(!number){ + if(number=''){ throw new EmptyParamaterException('Number'); } - if(!shape){ + if(shape==''){ throw new EmptyParamaterException('Shape'); } - if(!filling){ + if(filling==''){ throw new EmptyParamaterException('Filling'); } + if(outline==''){ + throw new EmptyParamaterException('Outline'); + } this.color=color; this.number=number; this.shape=shape; this.filling=filling; + this.outline=outline; } /** * @returns array of all attributes : @@ -27,10 +31,10 @@ class Card{ * @author Bastien Jacquelin */ getAttributes(){ - return [this.color,this.number,this.shape,this.filling]; + return [this.color,this.number,this.shape,this.filling,this.outline]; } equals(card){ - return this.color===card.color && this.number===card.number && this.shape===card.shape && this.filling===card.filling; + return this.color===card.color && this.number===card.number && this.shape===card.shape && this.filling===card.filling && this.outline===card.outline ; } }//export {Card} \ No newline at end of file diff --git a/src/Model/Const.js b/src/Model/Const.js new file mode 100644 index 0000000..201e43e --- /dev/null +++ b/src/Model/Const.js @@ -0,0 +1,6 @@ +const tabColor = ['red','purple','green','blue','orange']; +const tabNumber = [1,2,3,4,5]; +const tabShape = ['diamond','oval','wave','star','triangle']; +const tabFilling = ['empty','stripped','full','pointed','squared']; +const tabOutline = ['full','dotted ','hyphen','cloudy','sharpy']; +const ATTRIBUTES=[tabColor,tabNumber,tabShape,tabFilling,tabOutline] \ No newline at end of file diff --git a/src/Model/Deck.js b/src/Model/Deck.js index 5be6949..40c365c 100644 --- a/src/Model/Deck.js +++ b/src/Model/Deck.js @@ -1,11 +1,40 @@ class Deck{ - constructor(nbAttributes=4){ - this.allCards=this.createCards(nbAttributes);// All the cards in the game + /** + * + * @param {*} attributes : array with the attributes index for the cards + */ + constructor(attributes,nbAttributes){ + let attributesRequired=this.attributesRequiredFun(attributes); + attributesRequired.forEach(e=>{ + for(let i=0;i {