From 5c54ffa32f89ca77cc2215ff9b0eb87d9d7f098a Mon Sep 17 00:00:00 2001 From: Bastien Jacquelin Date: Tue, 28 Feb 2023 15:51:09 +0100 Subject: [PATCH] get dictionnary of attributes, key and value --- src/Model/Const.js | 3 ++- src/Model/Factory.js | 36 ++++++++++++++++++++++++++++++------ 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/src/Model/Const.js b/src/Model/Const.js index 33ff496..4337dcf 100644 --- a/src/Model/Const.js +++ b/src/Model/Const.js @@ -3,4 +3,5 @@ const TAB_NUMBER = [1,2,3,4,5]; const TAB_SHAPE = ['diamond','oval','wave','star','triangle']; const TAB_FILLING = ['empty','stripped','full','pointed','squared']; const TAB_OUTLINE = ['full','dotted','hyphen','cloudy','sharpy']; -const ATTRIBUTES=[TAB_COLOR,TAB_NUMBER,TAB_SHAPE,TAB_FILLING,TAB_OUTLINE] \ No newline at end of file +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 diff --git a/src/Model/Factory.js b/src/Model/Factory.js index 39d54bc..c012249 100644 --- a/src/Model/Factory.js +++ b/src/Model/Factory.js @@ -3,17 +3,41 @@ class Factory{ let length=arrayOfAttributes.length this.product=this.concreteCardCreation(arrayOfAttributes,length); console.log("arrayOfAttributes",this.funArrayOfAttributes(arrayOfAttributes)); + console.log("attributesDictionnary",this.attributesDictionnary(arrayOfAttributes,this.funArrayOfAttributes(arrayOfAttributes))) } - funArrayOfAttributes(arrayOfAttributes){ + /** + * + * @param {*} arrayOfIdxAttributes index of attributes in ATTRIBUTES + * @returns array of all attributes + */ + funArrayOfAttributes(arrayOfIdxAttributes){ let attr=[]; - let l=arrayOfAttributes.length; - arrayOfAttributes.forEach(e => { - for (let i=0;i { + for (let i=0;i