diff --git a/src/Console/Console.html b/src/Console/Console.html index 77df2ba..991d7c0 100644 --- a/src/Console/Console.html +++ b/src/Console/Console.html @@ -15,12 +15,6 @@ - - - - - - diff --git a/src/Console/main.js b/src/Console/main.js index 5ac12c1..cb2a25e 100644 --- a/src/Console/main.js +++ b/src/Console/main.js @@ -66,4 +66,4 @@ const list2 = [1, 1, 1, 1]; console.log(checkList(list2)); // Retourne 1 const list3 = [1, 2, 3, 1]; -console.log(checkList(list3)); // Retourne 2 \ No newline at end of file +console.log(checkList(list3)); // Retourne 2 diff --git a/src/Model/Card.js b/src/Model/Card.js index 45c5972..864bac6 100644 --- a/src/Model/Card.js +++ b/src/Model/Card.js @@ -1,15 +1,34 @@ class Card{ - constructor(){} + /** + * + * @param {*} attributes : dictionnary of attributes : key : name of the attributes and value : value of the attributes + */ + constructor(attributes){ + this.attributes=attributes; + } /** * * @returns all attributes of a card */ - getAttributes(){} + getAttributes(){//working✅ + let att=[]; + Object.entries(this.attributes).forEach(function([key, value]) { + att.push(value); + }); + return att; + } /** * * @param {*} card card to be compared with the current obj * @returns boolean */ - equals(card){} - -}//export {Card} \ No newline at end of file + equals(card){//working✅ + let bool=true; + Object.entries(this.attributes).forEach(function([key, value]) { + if(card.attributes[key]!=value){ + bool=false; + } + }); + return bool; + } +} \ No newline at end of file diff --git a/src/Model/Card4WithoutColor.js b/src/Model/Card4WithoutColor.js deleted file mode 100644 index cbad689..0000000 --- a/src/Model/Card4WithoutColor.js +++ /dev/null @@ -1,27 +0,0 @@ -class Card4WithoutColor extends Card{ - constructor(number, shape, filling, outline){ - super(); - if(number==''){ - throw new EmptyParamaterException('Number'); - } - if(shape==''){ - throw new EmptyParamaterException('Shape'); - } - if(filling==''){ - throw new EmptyParamaterException('Filling'); - } - if(outline==''){ - throw new EmptyParamaterException('Outline'); - } - this.number=number; - this.shape=shape; - this.filling=filling; - this.outline=outline; - } - getAttributes(){ - return [this.number,this.shape,this.filling,this.outline]; - } - equals(card){ - return this.number===card.number && this.shape===card.shape && this.filling===card.filling && this.outline===card.outline ; - } -} \ No newline at end of file diff --git a/src/Model/Card4WithoutFilling.js b/src/Model/Card4WithoutFilling.js deleted file mode 100644 index b895c07..0000000 --- a/src/Model/Card4WithoutFilling.js +++ /dev/null @@ -1,27 +0,0 @@ -class Card4WithoutFilling extends Card{ - constructor(color,number, shape, outline){ - super(); - if(number==''){ - throw new EmptyParamaterException('Number'); - } - if(shape==''){ - throw new EmptyParamaterException('Shape'); - } - if(color==''){ - throw new EmptyParamaterException('Color'); - } - if(outline==''){ - throw new EmptyParamaterException('Outline'); - } - this.number=number; - this.shape=shape; - this.color=color; - this.outline=outline; - } - getAttributes(){ - return [this.number,this.shape,this.color,this.outline]; - } - equals(card){ - return this.number===card.number && this.shape===card.shape && this.color===card.color && this.outline===card.outline ; - } -} \ No newline at end of file diff --git a/src/Model/Card4WithoutNumber.js b/src/Model/Card4WithoutNumber.js deleted file mode 100644 index 95abc61..0000000 --- a/src/Model/Card4WithoutNumber.js +++ /dev/null @@ -1,27 +0,0 @@ -class Card4WithoutNumber extends Card{ - constructor(color, shape, filling, outline){ - super(); - if(color==''){ - throw new EmptyParamaterException('Color'); - } - if(shape==''){ - throw new EmptyParamaterException('Shape'); - } - if(filling==''){ - throw new EmptyParamaterException('Filling'); - } - if(outline==''){ - throw new EmptyParamaterException('Outline'); - } - this.color=color; - this.shape=shape; - this.filling=filling; - this.outline=outline; - } - getAttributes(){ - return [this.color,this.shape,this.filling,this.outline]; - } - equals(card){ - return this.color===card.color && this.shape===card.shape && this.filling===card.filling && this.outline===card.outline ; - } -} \ No newline at end of file diff --git a/src/Model/Card4WithoutOutline.js b/src/Model/Card4WithoutOutline.js deleted file mode 100644 index b1db83c..0000000 --- a/src/Model/Card4WithoutOutline.js +++ /dev/null @@ -1,27 +0,0 @@ -class Card4WithoutOutline extends Card{ - constructor(color, number, shape, filling){ - super(); - if(color==''){ - throw new EmptyParamaterException('Color'); - } - if(number==''){ - throw new EmptyParamaterException('Number'); - } - if(shape==''){ - throw new EmptyParamaterException('Shape'); - } - if(filling==''){ - throw new EmptyParamaterException('Filling'); - } - this.color=color; - this.number=number; - this.shape=shape; - this.filling=filling; - } - getAttributes(){ - return [this.color,this.number,this.shape,this.filling]; - } - equals(card){ - return this.number===card.number && this.shape===card.shape && this.filling===card.filling && this.color===card.color; - } -} \ No newline at end of file diff --git a/src/Model/Card4WithoutShape.js b/src/Model/Card4WithoutShape.js deleted file mode 100644 index bf0d36c..0000000 --- a/src/Model/Card4WithoutShape.js +++ /dev/null @@ -1,27 +0,0 @@ -class Card4WithoutShape extends Card{ - constructor(color,number, filling, outline){ - super(); - if(color==''){ - throw new EmptyParamaterException('Color'); - } - if(number==''){ - throw new EmptyParamaterException('Number'); - } - if(filling==''){ - throw new EmptyParamaterException('Filling'); - } - if(outline==''){ - throw new EmptyParamaterException('Outline'); - } - this.color=color; - this.number=number; - this.filling=filling; - this.outline=outline; - } - getAttributes(){ - return [this.number,this.color,this.filling,this.outline]; - } - equals(card){ - return this.number===card.number && this.color===card.color && this.filling===card.filling && this.outline===card.outline ; - } -} \ No newline at end of file diff --git a/src/Model/Card5.js b/src/Model/Card5.js deleted file mode 100644 index a22e47a..0000000 --- a/src/Model/Card5.js +++ /dev/null @@ -1,43 +0,0 @@ -// import('.Card'); - -class Card5 extends Card { - constructor(color, number, shape, filling, outline){ - super(); - if(color==''){ - throw new EmptyParamaterException('Color'); - } - if(number==''){ - throw new EmptyParamaterException('Number'); - } - if(shape==''){ - throw new EmptyParamaterException('Shape'); - } - 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 : - idx 1 : color - idx 2 : number - idx 3 : shape - idx 4 : filling - idx 5 : outline - * @author Bastien Jacquelin - */ - getAttributes(){ - 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 && this.outline===card.outline ; - } -} -// export {Card5}; \ No newline at end of file diff --git a/src/Model/Const.js b/src/Model/Const.js index 3fae447..9c492fd 100644 --- a/src/Model/Const.js +++ b/src/Model/Const.js @@ -4,4 +4,4 @@ const TAB_SHAPE = ['diamond','oval','wave','star','triangle']; const TAB_FILLING = ['empty','stripped','full','pointed','squared']; const TAB_OUTLINE = ['continuous','dotted','hyphen','cloudy','sharpy']; const ATTRIBUTES=[TAB_COLOR,TAB_NUMBER,TAB_SHAPE,TAB_FILLING,TAB_OUTLINE]; -const IDX_ATTRIBUTES=["color","number","shape","filling","outline"]; \ No newline at end of file +const IDX_ATTRIBUTES=["color","number","shape","filling","outline"]; diff --git a/src/Model/Deck.js b/src/Model/Deck.js index c4c7b41..3bef3cf 100644 --- a/src/Model/Deck.js +++ b/src/Model/Deck.js @@ -5,22 +5,30 @@ class Deck{ * @author Bastien Jacquelin */ constructor(attributes,nbCards){ - //console.log(attributes); + this.nbCards=nbCards;// number of card to do a set this.allCards=this.createCards(attributes);// All the cards in the game - this.remainingCards=[] - this.nbCards=nbCards; - this.remainingCards=this.remainingCards.concat(this.allCards);// cards in the stack + this.remainingCards=[];//init tab null + this.remainingCards=this.remainingCards.concat(this.allCards);// cards in the stack, init = all before creation of deck -> remove this.outputCards=[];// 12 cards lay on the table this.setMade=[];// array of array with all the set already mades (array of set) this.createDeck(12); } - /** - * @brief creation of the deck : 12 cards lay in front of the player + * + * @param attributes : index of the attributes used + * @returns all cards: 81 in case of 4 attributes and 1024 if 5 attributes * @author Bastien Jacquelin */ - createDeck(nbCards){ - if(this.remainingCards.length==0){ + createCards(attributes){//working✅ + let factory = new Factory(attributes,this.nbCards); + return factory.product; + } + /** + * @brief creation of the deck : 12 random cards lay in front of the playe and remove card from the remainingCard array + * @author Bastien Jacquelin + */ + createDeck(nbCards){//toTest⌛ + if(this.remainingCards.length { for(let i=0; i { + for (let i=0;i