From 41e48013cdfa014ade5a864d7358cb17ad086efc Mon Sep 17 00:00:00 2001 From: Raphael LACOTE Date: Thu, 23 Feb 2023 15:23:30 +0100 Subject: [PATCH 1/7] MAJ Algo --- src/algo.js | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/src/algo.js b/src/algo.js index 8f0ab21..9ee8cf8 100644 --- a/src/algo.js +++ b/src/algo.js @@ -131,4 +131,77 @@ function setsCounter(deck, numberForSet){ console.error('The number of cards in a Set is not existing', numberForSet) } +function createElements(attributs1, attributs2) { + if (attributs1 in tabColor) { + tabColor.forEach(element => { + if (element != attributs1) { + if (element != attributs2) { + return element; + } + } + }); + } + if (attributs1 in tabNumber) { + tabNumber.forEach(element => { + if (element != attributs1) { + if (element != attributs2) { + return element; + } + } + }); + } + if (attributs1 in tabShape) { + tabShape.forEach(element => { + if (element != attributs1) { + if (element != attributs2) { + return element; + } + } + }); + } + if (attributs1 in tabFilling) { + tabFilling.forEach(element => { + if (element != attributs1) { + if (element != attributs2) { + return element; + } + } + }); + } + if (attributs1 in tabOutline) { + tabOutline.forEach(element => { + if (element != attributs1) { + if (element != attributs2) { + return element; + } + } + }); + } +} + +function createCard(cards) { + + let attributesMatrix = []; + let carteFinale = []; + + cards.forEach(element => { + attributesMatrix.push(element.getAttributes()); + }); + + for (let i = 0; i < attributesMatrix[0].length; i++) { + if (attributesMatrix[0][i] == attributesMatrix[1][i]) { + carteFinale.push(attributesMatrix[0][i]); + } + else { + carteFinale.push(createElements(attributesMatrix[0][i], attributesMatrix[1][i])) + } + } + + return carteFinale; + +} + +function isHyperset(cardsLeft, cardsRight) { + return createCard(cardsLeft).join() == createCard(cardsRight).join(); +} From 1f6aa89b69d434fa305b8ec4b842554726caa4fd Mon Sep 17 00:00:00 2001 From: Raphael LACOTE Date: Thu, 23 Feb 2023 15:25:20 +0100 Subject: [PATCH 2/7] MAJ Main --- src/Console/main.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/Console/main.js b/src/Console/main.js index 6646e7b..91a908a 100644 --- a/src/Console/main.js +++ b/src/Console/main.js @@ -110,4 +110,21 @@ for (let i=0; i<26;i++){ console.log(e.getAttributes()); }); } -deck.checkSet(customCard); \ No newline at end of file +deck.checkSet(customCard); + +// CREATE HYPERSET + +let Hcard1 = new Card4WithoutOutline('red', '3', 'diamond', 'full'); +let Hcard2 = new Card4WithoutOutline('red', '2', 'diamond', 'full'); +let Hcard3 = new Card4WithoutOutline('blue', '2', 'diamond', 'stripped'); +let Hcard4 = new Card4WithoutOutline('green', '3', 'diamond', 'empty'); + +deckA = []; +deckB = []; + +deckA.push(Hcard1); +deckA.push(Hcard2); +deckB.push(Hcard3); +deckB.push(Hcard4); + +console.log(isHyperset(deckA, deckB)); \ No newline at end of file From caad23ffbef6598e746ba4629992a43319bf4ce1 Mon Sep 17 00:00:00 2001 From: Raphael LACOTE Date: Thu, 23 Feb 2023 21:40:21 +0100 Subject: [PATCH 3/7] Fonction hyperset fonctionnant pour n'importe quel nombre de cartes et d'attributs --- src/Console/main.js | 58 +++++++++++++++--- src/Model/Const.js | 6 +- src/algo.js | 142 +++++++++++++++++++++++++++----------------- 3 files changed, 142 insertions(+), 64 deletions(-) diff --git a/src/Console/main.js b/src/Console/main.js index 91a908a..fc99f74 100644 --- a/src/Console/main.js +++ b/src/Console/main.js @@ -1,8 +1,8 @@ -// import { Card5 } from "../Model/Card5"; -// import('../Model/Card5'); +//import { Card5 } from "../Model/Card5"; +//import('../Model/Card5'); //import {Card} from '../Model/Card'; -console.log("~#Test#~"); +/*console.log("~#Test#~"); let card4 = new Card4WithoutOutline('red','2','losange','full'); console.group('Carte 4 attributes'); console.log(`carte de 4 elements : ${card4.color}`); @@ -110,14 +110,39 @@ for (let i=0; i<26;i++){ console.log(e.getAttributes()); }); } -deck.checkSet(customCard); +deck.checkSet(customCard);*/ // CREATE HYPERSET -let Hcard1 = new Card4WithoutOutline('red', '3', 'diamond', 'full'); -let Hcard2 = new Card4WithoutOutline('red', '2', 'diamond', 'full'); -let Hcard3 = new Card4WithoutOutline('blue', '2', 'diamond', 'stripped'); -let Hcard4 = new Card4WithoutOutline('green', '3', 'diamond', 'empty'); +function checkList(list) { + // Vérifier si tous les éléments sont identiques + if (list.every(element => element === list[0])) { + return 1; + } + + if ([...new Set(list)].length === list.length) { + return 0; + } + + // Si tous les éléments ne sont ni identiques ni différents + return 2; +} + +// Exemple d'utilisation +const list1 = [1, 2, 3, 4]; +console.log(checkList(list1)); // Retourne 0 + +const list2 = [1, 1, 1, 1]; +console.log(checkList(list2)); // Retourne 1 + +const list3 = [1, 2, 3, 1]; +console.log(checkList(list3)); // Retourne 2 + + +let Hcard1 = new Card4WithoutOutline('red', 3, 'wave', 'full'); +let Hcard2 = new Card4WithoutOutline('red', 3, 'oval', 'empty'); +let Hcard3 = new Card4WithoutOutline('blue', 2, 'oval', 'full'); +let Hcard4 = new Card4WithoutOutline('green', 1, 'wave', 'full'); deckA = []; deckB = []; @@ -127,4 +152,19 @@ deckA.push(Hcard2); deckB.push(Hcard3); deckB.push(Hcard4); -console.log(isHyperset(deckA, deckB)); \ No newline at end of file +console.log(isHyperset(deckA, deckB)); + +let Icard1 = new Card5('red', 4, 'oval', 'empty','fullO'); +let Icard2 = new Card5('red', 3, 'oval', 'full','fullO'); +let Icard3 = new Card5('red', 2, 'oval', 'squared','fullO'); +let Icard4 = new Card5('green', 2, 'oval', 'pointed','cloudy'); +let Icard5 = new Card5('blue', 3, 'oval', 'squared','sharpy'); +let Icard6 = new Card5('purple', 4, 'oval', 'full','hyphen'); + +deckAA = []; +deckBB = []; + +deckAA.push(Icard1, Icard2, Icard3); +deckBB.push(Icard4, Icard5, Icard6); + +console.log(isHyperset(deckAA, deckBB)); diff --git a/src/Model/Const.js b/src/Model/Const.js index 201e43e..3cab74b 100644 --- a/src/Model/Const.js +++ b/src/Model/Const.js @@ -2,5 +2,7 @@ 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 +const tabOutline = ['fullO','dotted ','hyphen','cloudy','sharpy']; +const ATTRIBUTES = [tabColor, tabNumber, tabShape, tabFilling, tabOutline] + +//Rename tabOutline \ No newline at end of file diff --git a/src/algo.js b/src/algo.js index 9ee8cf8..19b7650 100644 --- a/src/algo.js +++ b/src/algo.js @@ -1,4 +1,4 @@ -import('./Model/Card.js') +//import('./Model/Card.js') function isSet(cards) @@ -131,77 +131,113 @@ function setsCounter(deck, numberForSet){ console.error('The number of cards in a Set is not existing', numberForSet) } -function createElements(attributs1, attributs2) { - if (attributs1 in tabColor) { - tabColor.forEach(element => { - if (element != attributs1) { - if (element != attributs2) { - return element; - } - } - }); - } - if (attributs1 in tabNumber) { - tabNumber.forEach(element => { - if (element != attributs1) { - if (element != attributs2) { - return element; - } - } - }); - } - if (attributs1 in tabShape) { - tabShape.forEach(element => { - if (element != attributs1) { - if (element != attributs2) { - return element; - } - } - }); - } - if (attributs1 in tabFilling) { - tabFilling.forEach(element => { - if (element != attributs1) { - if (element != attributs2) { - return element; - } +function createElements(attributsCartes, listeAttributs) { + let l = [] + let verif; + listeAttributs.forEach(element => { + verif = false; + attributsCartes.forEach(attribCartes => { + if (element == attribCartes) { + verif = true; } - }); - } - if (attributs1 in tabOutline) { - tabOutline.forEach(element => { - if (element != attributs1) { - if (element != attributs2) { - return element; - } - } - }); - } + }) + if (verif == false) { + l.push(element); + } + }); + return l +} + +function trouveElements(attributsCartes) { + + let x; + + tabColor.forEach(element => { + if (element == attributsCartes[0]) { + x = createElements(attributsCartes, tabColor); + } + }); + + tabNumber.forEach(element => { + if (element == attributsCartes[0]) { + x = createElements(attributsCartes, tabNumber); + } + }); + + tabShape.forEach(element => { + if (element == attributsCartes[0]) { + x = createElements(attributsCartes, tabShape); + } + }); + + tabFilling.forEach(element => { + if (element == attributsCartes[0]) { + x = createElements(attributsCartes, tabFilling); + } + }); + + tabOutline.forEach(element => { + if (element == attributsCartes[0]) { + x = createElements(attributsCartes, tabOutline); + } + }); + + return x; } function createCard(cards) { let attributesMatrix = []; let carteFinale = []; + let listeInter = []; cards.forEach(element => { attributesMatrix.push(element.getAttributes()); }); for (let i = 0; i < attributesMatrix[0].length; i++) { - if (attributesMatrix[0][i] == attributesMatrix[1][i]) { - carteFinale.push(attributesMatrix[0][i]); + listeInter = []; + attributesMatrix.forEach(element => { + listeInter.push(element[i]); + }); + + //S'ils sont tous égaux + if (listeInter.every(element => element === listeInter[0])) { + carteFinale.push(listeInter[0]); } else { - carteFinale.push(createElements(attributesMatrix[0][i], attributesMatrix[1][i])) + //S'ils sont tous différents + if ([...new Set(listeInter)].length === listeInter.length) { + carteFinale.push(trouveElements(listeInter)); + } + //Sinon + else { + carteFinale.push([]); + } } } + console.log(carteFinale); return carteFinale; - } function isHyperset(cardsLeft, cardsRight) { - return createCard(cardsLeft).join() == createCard(cardsRight).join(); -} - + left = createCard(cardsLeft) + right = createCard(cardsRight) + let verif; + + for (let i = 0; i < left[0].length; i++) { + verif = false; + left.forEach(elementG => { + right.forEach(elementD => { + if (elementD == elementG) { + verif=true + } + }) + }) + if (verif == false) { + return false; + } + } + return true; +} \ No newline at end of file From 580ebb3d14524f2785913ba2ee382e38c0be8709 Mon Sep 17 00:00:00 2001 From: Raphael LACOTE Date: Tue, 28 Feb 2023 11:42:58 +0100 Subject: [PATCH 4/7] =?UTF-8?q?=C3=A9criture=20des=20Tests=20unitaire=20et?= =?UTF-8?q?=20rectification=20d'un=20bug=20de=20la=20fonction=20isHyperset?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Console/Console.html | 5 ++-- src/Console/main.js | 4 +-- src/Console/test.js | 61 ++++++++++++++++++++++++++++++++++++++++ src/Model/Const.js | 4 +-- src/algo.js | 11 +++++--- test/testsIsHyperset.js | 61 ++++++++++++++++++++++++++++++++++++++++ 6 files changed, 136 insertions(+), 10 deletions(-) create mode 100644 src/Console/test.js create mode 100644 test/testsIsHyperset.js diff --git a/src/Console/Console.html b/src/Console/Console.html index 23876d4..b772f30 100644 --- a/src/Console/Console.html +++ b/src/Console/Console.html @@ -11,7 +11,6 @@

Console - test

-
@@ -25,7 +24,9 @@ - + + + \ No newline at end of file diff --git a/src/Console/main.js b/src/Console/main.js index fc99f74..68242e4 100644 --- a/src/Console/main.js +++ b/src/Console/main.js @@ -2,7 +2,7 @@ //import('../Model/Card5'); //import {Card} from '../Model/Card'; -/*console.log("~#Test#~"); +console.log("~#Test#~"); let card4 = new Card4WithoutOutline('red','2','losange','full'); console.group('Carte 4 attributes'); console.log(`carte de 4 elements : ${card4.color}`); @@ -110,7 +110,7 @@ for (let i=0; i<26;i++){ console.log(e.getAttributes()); }); } -deck.checkSet(customCard);*/ +deck.checkSet(customCard); // CREATE HYPERSET diff --git a/src/Console/test.js b/src/Console/test.js new file mode 100644 index 0000000..87d1816 --- /dev/null +++ b/src/Console/test.js @@ -0,0 +1,61 @@ +let card1 = new Card4WithoutOutline('red', 3, 'wave', 'full'); +let card2 = new Card4WithoutOutline('red', 3, 'oval', 'empty'); +let card3 = new Card4WithoutOutline('blue', 2, 'oval', 'full'); +let card4 = new Card4WithoutOutline('green', 1, 'wave', 'pointed'); +let card5 = new Card4WithoutOutline('green', 1, 'wave', 'full'); + +deckA = []; +deckB = []; +deckC = []; + +deckA.push(card1, card2); +deckB.push(card3, card4); +deckC.push(card3, card5); + +console.assert(isHyperset(deckA, deckB) == true); +console.assert(isHyperset(deckA, deckC) == false); + +let BcardG1 = new Card5('red', 4, 'oval', 'empty', 'fullO'); +let BcardG2 = new Card5('red', 3, 'oval', 'full', 'fullO'); +let BcardG3 = new Card5('red', 2, 'oval', 'squared', 'fullO'); +let BcardG4 = new Card5('red', 1, 'oval', 'pointed', 'fullO'); + +let BcardD1 = new Card5('green', 3, 'oval', 'pointed', 'cloudy'); +let BcardD2 = new Card5('blue', 2, 'oval', 'squared', 'sharpy'); +let BcardD3 = new Card5('purple', 4, 'oval', 'full', 'hyphen'); +let BcardD4 = new Card5('orange', 1, 'oval', 'empty', 'dotted'); +let BcardD5 = new Card5('purple', 4, 'oval', 'stripped', 'hyphen'); + +BdeckA = []; +BdeckB = []; +BdeckC = []; +BdeckD = []; +BdeckE = []; + + +BdeckA.push(BcardG1, BcardG2, BcardG3); +BdeckB.push(BcardD1, BcardD2, BcardD3); +BdeckC.push(BcardD1, BcardD2, BcardD5); +BdeckD.push(BcardG1, BcardG2, BcardG3,BcardG4); +BdeckE.push(BcardD1, BcardD2, BcardD3,BcardD4); + +console.assert(isHyperset(BdeckA, BdeckB) == true); +console.assert(isHyperset(BdeckA, BdeckC) == false); +console.assert(isHyperset(BdeckD, BdeckE) == true); + + +let Ccard1 = new Card4WithoutShape('blue', 3, 'empty', 'cloudy'); +let Ccard2 = new Card4WithoutShape('red', 3, 'empty', 'cloudy'); +let Ccard3 = new Card4WithoutShape('green', 3, 'empty', 'cloudy'); +let Ccard4 = new Card4WithoutShape('purple', 3, 'empty', 'sharpy'); +let Ccard5 = new Card4WithoutShape('purple', 3, 'empty', 'sharpy'); +let Ccard6 = new Card4WithoutShape('purple', 3, 'empty', 'sharpy'); + +CdeckA = []; +CdeckB = []; + +CdeckA.push(Ccard1, Ccard2, Ccard3); +CdeckB.push(Ccard4, Ccard5, Ccard6); + +console.assert(isHyperset(CdeckA, CdeckB) == false); + diff --git a/src/Model/Const.js b/src/Model/Const.js index 3cab74b..801313e 100644 --- a/src/Model/Const.js +++ b/src/Model/Const.js @@ -2,7 +2,7 @@ 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 = ['fullO','dotted ','hyphen','cloudy','sharpy']; +const tabOutline = ['fullO','dotted','hyphen','cloudy','sharpy']; const ATTRIBUTES = [tabColor, tabNumber, tabShape, tabFilling, tabOutline] -//Rename tabOutline \ No newline at end of file +//Rename tabOutline first attributs \ No newline at end of file diff --git a/src/algo.js b/src/algo.js index 19b7650..b739892 100644 --- a/src/algo.js +++ b/src/algo.js @@ -203,7 +203,9 @@ function createCard(cards) { //S'ils sont tous égaux if (listeInter.every(element => element === listeInter[0])) { - carteFinale.push(listeInter[0]); + l = [] + l.push(listeInter[0]) + carteFinale.push(l); } else { //S'ils sont tous différents @@ -226,10 +228,11 @@ function isHyperset(cardsLeft, cardsRight) { right = createCard(cardsRight) let verif; - for (let i = 0; i < left[0].length; i++) { + for (let i = 0; i < left.length; i++) { + verif = false; - left.forEach(elementG => { - right.forEach(elementD => { + left[i].forEach(elementG => { + right[i].forEach(elementD => { if (elementD == elementG) { verif=true } diff --git a/test/testsIsHyperset.js b/test/testsIsHyperset.js new file mode 100644 index 0000000..9c4d9ca --- /dev/null +++ b/test/testsIsHyperset.js @@ -0,0 +1,61 @@ +let card1 = new Card4WithoutOutline('red', 3, 'wave', 'full'); +let card2 = new Card4WithoutOutline('red', 3, 'oval', 'empty'); +let card3 = new Card4WithoutOutline('blue', 2, 'oval', 'full'); +let card4 = new Card4WithoutOutline('green', 1, 'wave', 'pointed'); +let card5 = new Card4WithoutOutline('green', 1, 'wave', 'full'); + +deckA = []; +deckB = []; +deckC = []; + +deckA.push(card1, card2); +deckB.push(card3, card4); +deckC.push(card3, card5); + +console.assert(isHyperset(deckA, deckB) == true); +console.assert(isHyperset(deckA, deckC) == false); + +let BcardG1 = new Card5('red', 4, 'oval', 'empty', 'fullO'); +let BcardG2 = new Card5('red', 3, 'oval', 'full', 'fullO'); +let BcardG3 = new Card5('red', 2, 'oval', 'squared', 'fullO'); +let BcardG4 = new Card5('red', 1, 'oval', 'pointed', 'fullO'); + +let BcardD1 = new Card5('green', 3, 'oval', 'pointed', 'cloudy'); +let BcardD2 = new Card5('blue', 2, 'oval', 'squared', 'sharpy'); +let BcardD3 = new Card5('purple', 4, 'oval', 'full', 'hyphen'); +let BcardD4 = new Card5('orange', 1, 'oval', 'empty', 'dotted'); +let BcardD5 = new Card5('purple', 4, 'oval', 'stripped', 'hyphen'); + +BdeckA = []; +BdeckB = []; +BdeckC = []; +BdeckD = []; +BdeckE = []; + + +BdeckA.push(BcardG1, BcardG2, BcardG3); +BdeckB.push(BcardD1, BcardD2, BcardD3); +BdeckC.push(BcardD1, BcardD2, BcardD5); +BdeckD.push(BcardG1, BcardG2, BcardG3, BcardG4); +BdeckE.push(BcardD1, BcardD2, BcardD3, BcardD4); + +console.assert(isHyperset(BdeckA, BdeckB) == true); +console.assert(isHyperset(BdeckA, BdeckC) == false); +console.assert(isHyperset(BdeckD, BdeckE) == true); + + +let Ccard1 = new Card4WithoutShape('blue', 3, 'empty', 'cloudy'); +let Ccard2 = new Card4WithoutShape('red', 3, 'empty', 'cloudy'); +let Ccard3 = new Card4WithoutShape('green', 3, 'empty', 'cloudy'); +let Ccard4 = new Card4WithoutShape('purple', 3, 'empty', 'sharpy'); +let Ccard5 = new Card4WithoutShape('purple', 3, 'empty', 'sharpy'); +let Ccard6 = new Card4WithoutShape('purple', 3, 'empty', 'sharpy'); + +CdeckA = []; +CdeckB = []; + +CdeckA.push(Ccard1, Ccard2, Ccard3); +CdeckB.push(Ccard4, Ccard5, Ccard6); + +console.assert(isHyperset(CdeckA, CdeckB) == false); + From 35cbeae91935f3ff7335bcdeaa29078c713d0235 Mon Sep 17 00:00:00 2001 From: Raphael LACOTE Date: Tue, 28 Feb 2023 11:47:39 +0100 Subject: [PATCH 5/7] =?UTF-8?q?D=C3=A9placement=20du=20test=20unitaire=20d?= =?UTF-8?q?ans=20le=20dossier=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Console/Console.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Console/Console.html b/src/Console/Console.html index b772f30..03955b3 100644 --- a/src/Console/Console.html +++ b/src/Console/Console.html @@ -24,9 +24,9 @@ - + - + \ No newline at end of file From 69be259fe98d2289c676dcb8c2ce0720749f1e0d Mon Sep 17 00:00:00 2001 From: Raphael LACOTE Date: Tue, 28 Feb 2023 11:55:32 +0100 Subject: [PATCH 6/7] Supression d'un fichier test inutile --- src/Console/test.js | 61 --------------------------------------------- 1 file changed, 61 deletions(-) delete mode 100644 src/Console/test.js diff --git a/src/Console/test.js b/src/Console/test.js deleted file mode 100644 index 87d1816..0000000 --- a/src/Console/test.js +++ /dev/null @@ -1,61 +0,0 @@ -let card1 = new Card4WithoutOutline('red', 3, 'wave', 'full'); -let card2 = new Card4WithoutOutline('red', 3, 'oval', 'empty'); -let card3 = new Card4WithoutOutline('blue', 2, 'oval', 'full'); -let card4 = new Card4WithoutOutline('green', 1, 'wave', 'pointed'); -let card5 = new Card4WithoutOutline('green', 1, 'wave', 'full'); - -deckA = []; -deckB = []; -deckC = []; - -deckA.push(card1, card2); -deckB.push(card3, card4); -deckC.push(card3, card5); - -console.assert(isHyperset(deckA, deckB) == true); -console.assert(isHyperset(deckA, deckC) == false); - -let BcardG1 = new Card5('red', 4, 'oval', 'empty', 'fullO'); -let BcardG2 = new Card5('red', 3, 'oval', 'full', 'fullO'); -let BcardG3 = new Card5('red', 2, 'oval', 'squared', 'fullO'); -let BcardG4 = new Card5('red', 1, 'oval', 'pointed', 'fullO'); - -let BcardD1 = new Card5('green', 3, 'oval', 'pointed', 'cloudy'); -let BcardD2 = new Card5('blue', 2, 'oval', 'squared', 'sharpy'); -let BcardD3 = new Card5('purple', 4, 'oval', 'full', 'hyphen'); -let BcardD4 = new Card5('orange', 1, 'oval', 'empty', 'dotted'); -let BcardD5 = new Card5('purple', 4, 'oval', 'stripped', 'hyphen'); - -BdeckA = []; -BdeckB = []; -BdeckC = []; -BdeckD = []; -BdeckE = []; - - -BdeckA.push(BcardG1, BcardG2, BcardG3); -BdeckB.push(BcardD1, BcardD2, BcardD3); -BdeckC.push(BcardD1, BcardD2, BcardD5); -BdeckD.push(BcardG1, BcardG2, BcardG3,BcardG4); -BdeckE.push(BcardD1, BcardD2, BcardD3,BcardD4); - -console.assert(isHyperset(BdeckA, BdeckB) == true); -console.assert(isHyperset(BdeckA, BdeckC) == false); -console.assert(isHyperset(BdeckD, BdeckE) == true); - - -let Ccard1 = new Card4WithoutShape('blue', 3, 'empty', 'cloudy'); -let Ccard2 = new Card4WithoutShape('red', 3, 'empty', 'cloudy'); -let Ccard3 = new Card4WithoutShape('green', 3, 'empty', 'cloudy'); -let Ccard4 = new Card4WithoutShape('purple', 3, 'empty', 'sharpy'); -let Ccard5 = new Card4WithoutShape('purple', 3, 'empty', 'sharpy'); -let Ccard6 = new Card4WithoutShape('purple', 3, 'empty', 'sharpy'); - -CdeckA = []; -CdeckB = []; - -CdeckA.push(Ccard1, Ccard2, Ccard3); -CdeckB.push(Ccard4, Ccard5, Ccard6); - -console.assert(isHyperset(CdeckA, CdeckB) == false); - From 33447f523efdb534b490273785c77bbb486e144e Mon Sep 17 00:00:00 2001 From: Raphael LACOTE Date: Tue, 28 Feb 2023 20:37:33 +0100 Subject: [PATCH 7/7] Supression de tests inutiles dans le main --- src/Console/Console.html | 1 - src/Console/main.js | 33 +-------------------------------- 2 files changed, 1 insertion(+), 33 deletions(-) diff --git a/src/Console/Console.html b/src/Console/Console.html index 03955b3..77df2ba 100644 --- a/src/Console/Console.html +++ b/src/Console/Console.html @@ -25,7 +25,6 @@ - diff --git a/src/Console/main.js b/src/Console/main.js index 68242e4..d1c0bd0 100644 --- a/src/Console/main.js +++ b/src/Console/main.js @@ -136,35 +136,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 - - -let Hcard1 = new Card4WithoutOutline('red', 3, 'wave', 'full'); -let Hcard2 = new Card4WithoutOutline('red', 3, 'oval', 'empty'); -let Hcard3 = new Card4WithoutOutline('blue', 2, 'oval', 'full'); -let Hcard4 = new Card4WithoutOutline('green', 1, 'wave', 'full'); - -deckA = []; -deckB = []; - -deckA.push(Hcard1); -deckA.push(Hcard2); -deckB.push(Hcard3); -deckB.push(Hcard4); - -console.log(isHyperset(deckA, deckB)); - -let Icard1 = new Card5('red', 4, 'oval', 'empty','fullO'); -let Icard2 = new Card5('red', 3, 'oval', 'full','fullO'); -let Icard3 = new Card5('red', 2, 'oval', 'squared','fullO'); -let Icard4 = new Card5('green', 2, 'oval', 'pointed','cloudy'); -let Icard5 = new Card5('blue', 3, 'oval', 'squared','sharpy'); -let Icard6 = new Card5('purple', 4, 'oval', 'full','hyphen'); - -deckAA = []; -deckBB = []; - -deckAA.push(Icard1, Icard2, Icard3); -deckBB.push(Icard4, Icard5, Icard6); - -console.log(isHyperset(deckAA, deckBB)); +console.log(checkList(list3)); // Retourne 2 \ No newline at end of file