public class Hand
{
//INSTANCE VARIABLES (OBJECTS)
public Card c1;
public Card c2;
public Card c3;
public Card c4;
public Card c5;
//CONSTRUCTORS
public Hand(Card
tc1, Card tc2, Card tc3, Card tc4, Card tc5)
{
c1 = tc1;
c2 = tc2;
c3 = tc3;
c4 = tc4;
c5 = tc5;
}
public Hand()
{
c1 = new
Card();
c2 = new
Card();
c3 = new
Card();
c4 = new
Card();
c5 = new
Card();
}
//INSTANCE METHODS
public Card getC1()
{
return c1;
}
public Card getC2()
{
return c2;
}
public Card getC3()
{
return c3;
}
public Card getC4()
{
return c4;
}
public Card getC5()
{
return c5;
}
public boolean isAllRed()
{
if(c1.isRed() && c2.isRed() && c3.isRed() && c4.isRed()
&& c5.isRed())
{
return true;
}
else
{
return false;
}
}
public boolean isAllBlack()
{
if(c1.isBlack() && c2.isBlack() && c3.isBlack() && c4.isBlack()
&& c5.isBlack())
{
return true;
}
else
{
return false;
}
}
public boolean containsPair()
{
if (c1.value == c2.value || c1.value == c3.value || c1.value == c4.value || c1.value == c5.value ||
c2.value == c3.value || c2.value == c4.value || c2.value == c5.value ||
c3.value == c4.value || c3.value == c5.value ||
c4.value == c5.value)
{
return true;
}
else
{
return false;
}
}
public String toString()
{
return c1 + ",
" + c2 + ", " + c3 + ", " + c4 + ", " + c5;
//above is calling the toString for each card object
}
}
|