jadex.bdi.examples.blackjack.Card Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jadex-applications-bdi Show documentation
Show all versions of jadex-applications-bdi Show documentation
The Jadex BDI applications package contain
several example applications, benchmarks and
testcases using BDI agents.
package jadex.bdi.examples.blackjack;
/**
* Card information.
*/
public class Card
{
//-------- attributes ----------
/** Attribute for slot col. */
protected String col;
/** Attribute for slot type. */
protected String type;
/** Attribute for slot val. */
protected int val;
//-------- constructors --------
/**
* Default Constructor.
* Create a new Card
.
*/
public Card()
{
// Empty constructor required for JavaBeans (do not remove).
}
/**
* Default Constructor.
* Create a new Card
.
*/
public Card(String type, String color, int value)
{
setType(type);
setColor(color);
setValue(value);
}
/**
* Clone Constructor.
* Create a new Card
.
* Copy all attributes from proto
to this instance.
* @param proto The prototype instance.
*/
public Card(Card proto)
{
setColor(proto.getColor());
setType(proto.getType());
setValue(proto.getValue());
}
//-------- accessor methods --------
/**
* Get the col of this Card.
* @return col
*/
public String getColor()
{
return this.col;
}
/**
* Set the col of this Card.
* @param col the value to be set
*/
public void setColor(String col)
{
this.col = col;
}
/**
* Get the type of this Card.
* @return type
*/
public String getType()
{
return this.type;
}
/**
* Set the type of this Card.
* @param type the value to be set
*/
public void setType(String type)
{
this.type = type;
}
/**
* Get the val of this Card.
* @return val
*/
public int getValue()
{
return this.val;
}
/**
* Set the val of this Card.
* @param val the value to be set
*/
public void setValue(int val)
{
this.val = val;
}
//-------- Object methods -----
/**
* Get a string representation of this Card
.
* @return The string representation.
*/
public String toString()
{
return getType() + " " + getColor();
}
/**
* Get a clone of this Card
.
* @return a shalow copy of this instance.
*/
public Object clone()
{
return new Card(this);
}
/**
* Test the equality of this Card
* and an object obj
.
* @param obj the object this test will be performed with
* @return false if obj
is not of Card
class,
* true if all attributes are equal.
*/
public boolean equals(Object obj)
{
if(obj instanceof Card)
{
Card cmp = (Card)obj;
if(getColor() != cmp.getColor() && (getColor() == null || !getColor().equals(cmp.getColor())))
return false;
if(getType() != cmp.getType() && (getType() == null || !getType().equals(cmp.getType())))
return false;
if(getValue() != cmp.getValue())
return false;
return true;
}
return false;
}
}