edit to work only with card, define funArrayOfAttributes
continuous-integration/drone/push Build is passing Details

pull/88/head
Bastien JACQUELIN 2 years ago
parent 82e97e1096
commit e87dec89fc

@ -94,20 +94,20 @@ console.groupEnd();
// CHECK SET // CHECK SET
console.log("~~CHECKING ALL SET~~") // console.log("~~CHECKING ALL SET~~")
for (let i=0; i<26;i++){ // for (let i=0; i<26;i++){
console.log(`-----${i}emme itérations-----`) // console.log(`-----${i}emme itérations-----`)
console.log("Card to remove: ") // console.log("Card to remove: ")
console.log(deck.outputCards[0].getAttributes(),deck.outputCards[1].getAttributes(),deck.outputCards[2].getAttributes()) // console.log(deck.outputCards[0].getAttributes(),deck.outputCards[1].getAttributes(),deck.outputCards[2].getAttributes())
customCard=[deck.outputCards[0],deck.outputCards[1],deck.outputCards[2]]; // customCard=[deck.outputCards[0],deck.outputCards[1],deck.outputCards[2]];
deck.checkSet(customCard); // deck.checkSet(customCard);
console.log(`remaining cards : ${deck.remainingCards.length}`) // console.log(`remaining cards : ${deck.remainingCards.length}`)
console.log(`All cards : ${deck.allCards.length}`) // console.log(`All cards : ${deck.allCards.length}`)
console.log(`size output ${deck.outputCards.length}`); // console.log(`size output ${deck.outputCards.length}`);
console.group('Output cards'); // console.group('Output cards');
deck.outputCards.forEach(e => { // deck.outputCards.forEach(e => {
console.log(e.getAttributes()); // console.log(e.getAttributes());
}); // });
} // }
deck.checkSet(customCard); // deck.checkSet(customCard);

@ -1,5 +1,15 @@
class Card{ class Card{
constructor(){} constructor(attributes){
this.attributes=attributes;
}
createAttributes(arrayOfAttributes){
}
/** /**
* *
* @returns all attributes of a card * @returns all attributes of a card

@ -1,6 +1,6 @@
const tabColor = ['red','purple','green','blue','orange']; const TAB_COLOR = ['red','purple','green','blue','orange'];
const tabNumber = [1,2,3,4,5]; const TAB_NUMBER = [1,2,3,4,5];
const tabShape = ['diamond','oval','wave','star','triangle']; const TAB_SHAPE = ['diamond','oval','wave','star','triangle'];
const tabFilling = ['empty','stripped','full','pointed','squared']; const TAB_FILLING = ['empty','stripped','full','pointed','squared'];
const tabOutline = ['full','dotted ','hyphen','cloudy','sharpy']; const TAB_OUTLINE = ['full','dotted','hyphen','cloudy','sharpy'];
const ATTRIBUTES=[tabColor,tabNumber,tabShape,tabFilling,tabOutline] const ATTRIBUTES=[TAB_COLOR,TAB_NUMBER,TAB_SHAPE,TAB_FILLING,TAB_OUTLINE]

@ -45,7 +45,6 @@ class Deck{
const random = Math.floor(Math.random() * this.remainingCards.length); const random = Math.floor(Math.random() * this.remainingCards.length);
return random; return random;
} }
/** /**
* *
* @param attributes : index of the attributes used * @param attributes : index of the attributes used
@ -53,8 +52,8 @@ class Deck{
* @author Bastien Jacquelin * @author Bastien Jacquelin
*/ */
createCards(attributes){ createCards(attributes){
let factory = new Factory(attributes) let factory = new Factory(attributes);
return factory.product return factory.product;
} }
/** /**

@ -2,7 +2,21 @@ class Factory{
constructor(arrayOfAttributes){ constructor(arrayOfAttributes){
let length=arrayOfAttributes.length let length=arrayOfAttributes.length
this.product=this.concreteCardCreation(arrayOfAttributes,length); this.product=this.concreteCardCreation(arrayOfAttributes,length);
console.log("arrayOfAttributes",this.funArrayOfAttributes(arrayOfAttributes));
} }
funArrayOfAttributes(arrayOfAttributes){
let attr=[];
let l=arrayOfAttributes.length;
arrayOfAttributes.forEach(e => {
for (let i=0;i<l;l++){
attr.push(e[i]);
}
});
}
/** /**
* @brief check if i in arrayOfAttributes * @brief check if i in arrayOfAttributes
* @param {*} i value * @param {*} i value
@ -35,6 +49,7 @@ class Factory{
attributesRequiredTmp.push(ATTRIBUTES[i]); attributesRequiredTmp.push(ATTRIBUTES[i]);
} }
} }
console.log('attributesRequiredFun',attributesRequiredTmp);
return attributesRequiredTmp; return attributesRequiredTmp;
} }
/** /**

Loading…
Cancel
Save