Errors:
Hand.java:36: error: cannot find symbol
if (e.getSuit().equals(theSuit))
^
symbol: method getSuit()
location: variable e of type Card
Hand.java:49: error: cannot find symbol
if (e.compareTo(min)<0)
^
symbol: method compareTo(Card)
location: variable e of type Card
import java.util.ArrayList;
public class Hand {
private ArrayList<Card> z;
public Hand()
{
z= new ArrayList <Card>();
}
//adds a card to the Hand.
public void add( Card xCard)
{
z.add(xCard);
}
//returns true if card is in hand, otherwise returns false
public boolean find(Card xCard)
{
for (Card e: z)
{ if (xCard== e)
return true;
}
return false;
}
//returns the number of cards in the hand that match the suit passed.
public int numCards(String theSuit)
{
int matches=0;
for (Card e: z)
{
if (e.getSuit().equals(theSuit))
matches++;
}
return matches;
}
//returns the card with the lowest card value.
public Card smallestValue()
{
Card min= z.get(0);
for (Card e: z)
{
if (e.compareTo(min)<0)
min=e;
}
return min;
}
//returns a string containing all the cards in the hand in a readable format.
public String toString()
{
String a = "";
for (Card e: z)
{
a +=e.toString() + "\n";
}
return a;
}
}

New Topic/Question
Reply



MultiQuote





|