resolve conflicts
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
commit
577375fae9
@ -1,15 +1,34 @@
|
|||||||
class Card{
|
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
|
* @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
|
* @param {*} card card to be compared with the current obj
|
||||||
* @returns boolean
|
* @returns boolean
|
||||||
*/
|
*/
|
||||||
equals(card){}
|
equals(card){//working✅
|
||||||
|
let bool=true;
|
||||||
}//export {Card}
|
Object.entries(this.attributes).forEach(function([key, value]) {
|
||||||
|
if(card.attributes[key]!=value){
|
||||||
|
bool=false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return bool;
|
||||||
|
}
|
||||||
|
}
|
@ -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 ;
|
|
||||||
}
|
|
||||||
}
|
|
@ -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 ;
|
|
||||||
}
|
|
||||||
}
|
|
@ -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 ;
|
|
||||||
}
|
|
||||||
}
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -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 ;
|
|
||||||
}
|
|
||||||
}
|
|
@ -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};
|
|
@ -0,0 +1,45 @@
|
|||||||
|
console.log("TEST FOR ISSET")
|
||||||
|
|
||||||
|
let card1 = new Card5("bleu","1","rond","remplis","plein")
|
||||||
|
let card2 = new Card5("bleu","2","rond","remplis","plein")
|
||||||
|
let card3 = new Card5("bleu","3","rond","remplis","plein")
|
||||||
|
let card4 = new Card5("bleu","4","rond","remplis","plein")
|
||||||
|
let card5 = new Card5("bleu","5","rond","remplis","plein")
|
||||||
|
|
||||||
|
let card6 = new Card5("vert","6","carre","vide","tapis")
|
||||||
|
|
||||||
|
|
||||||
|
let realSet = [card1,card2,card3,card4,card5]
|
||||||
|
let unRealSet = [card2,card3,card4,card5,card6]
|
||||||
|
|
||||||
|
console.group("FOR SET OF 5")
|
||||||
|
|
||||||
|
console.log("Number of Sets -> 1")
|
||||||
|
console.assert(numberOfSets5(realSet)==1)
|
||||||
|
|
||||||
|
console.log("Number of Sets -> 0")
|
||||||
|
console.assert(numberOfSets5(unRealSet)==0)
|
||||||
|
|
||||||
|
console.groupEnd()
|
||||||
|
|
||||||
|
|
||||||
|
card1 = new Card4WithoutColor("1","rond","plein","tapis")
|
||||||
|
card2 = new Card4WithoutColor("2","rond","plein","tapis")
|
||||||
|
card3 = new Card4WithoutColor("3","rond","plein","tapis")
|
||||||
|
card4 = new Card4WithoutColor("4","rond","plein","tapis")
|
||||||
|
|
||||||
|
card5 = new Card4WithoutColor("4","carre","vide","plein")
|
||||||
|
|
||||||
|
realSet = [card1,card2,card3,card4]
|
||||||
|
unRealSet = [card2,card3,card4,card5]
|
||||||
|
|
||||||
|
|
||||||
|
console.group("FOR SET OF 4")
|
||||||
|
|
||||||
|
console.log("Number of Sets -> 1")
|
||||||
|
console.assert(numberOfSets4(realSet)==1)
|
||||||
|
|
||||||
|
console.log("Number of Sets -> 0")
|
||||||
|
console.assert(numberOfSets4(unRealSet)==0)
|
||||||
|
|
||||||
|
console.groupEnd()
|
Loading…
Reference in new issue