card class only, can take multiple attributes, deck and card creation to do
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
65f1bab97b
commit
4951e2b8e1
@ -1,25 +1,34 @@
|
||||
class Card{
|
||||
/**
|
||||
*
|
||||
* @param {*} attributes : dictionnary of attributes : key : name of the attributes and value : value of the attributes
|
||||
*/
|
||||
constructor(attributes){
|
||||
this.attributes=attributes;
|
||||
}
|
||||
createAttributes(arrayOfAttributes){
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @returns all attributes of a card
|
||||
*/
|
||||
getAttributes(){}
|
||||
getAttributes(){
|
||||
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}
|
||||
equals(card){
|
||||
let bool=true;
|
||||
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};
|
Loading…
Reference in new issue