Hi need a little help I cant see whats wrong with this code can someone take a look at this and steer me in the right direction.
Specs say: I have to make hands comparable. I only comparing hands of the same length. One hand is bigger than another if the largest card of the first hand is larger than the largest card of the second hand:
public int compareTo(Hand otherHand)
{
for (int i=theHand.length; i >theHand.length; i--)
{
if (getHand()[i]!= otherHand.getHand()[i])
return getHand()[i].compareTo( otherHand.getHand()[i]);
}
return 0;
}
In my driver this is what I have
int biggestHand = playerHand.compareTo (computerHand);
if (biggestHand > 0)
JOptionPane.showMessageDialog(player wins);
else if (biggestHand < 0)
JOptionPane.showMessageDialog(computers wins);
else
JOptionPane.showMessageDialog(tie);
it keeps tieing.