I am a learning java, I am not very experienced but do enjoy programming. I am using the BlueJ compiler (which i have grown to like) and I can't seem to get this code to compile. The error is.....
"cannot find symbol - method add(CardGroup)"
i posted my code below. The error occurs in the second add() method (the one that passes a CardGroup parameter). I have been working at this code for a long while now and just don't seem to understand why I can't fix this error. I want to understand why I can't make this work so if you wouldn't mind explaining what my error is I would appreciate it.
Here is a bit of my logic.
What I want to do is be able to pass a set of cards (numerous) into the method and add them to my the current objects cards. From what I understand, if I had two objects and one of them was going to give the other objects his cards, this method would execute that. So my thought was to just use the add() or addAll() built in function for arrays. I have tried numerous things on this method, but I have gotten to the point where it is doing more harm than good playing with it. Also not, some of the other code is not complete, and that is intentional, once i get this method to work, i can finish the rest. hence the reason that half of it is void or noted out.
Thanks for your help guys, I appreciate it.
import java.util.*;
public class CardGroup
{
int R = 0;
String Stringing;
Card Spades;
Card Hearts;
Card Clubs;
Card Diamonds;
Card Last;
ArrayList<Card> Group = new ArrayList<Card>();
public CardGroup()
{
}
public void newDeck()
{
for(int j = 1; j <= 13; j++)
{
Spades = new Card(j , Suit.spades);
Group.add(Spades);
}
for(int j = 1; j <= 13; j++)
{
Hearts = new Card(j , Suit.hearts);
Group.add(Hearts);
}
for(int j = 1; j <= 13; j++)
{
Clubs = new Card(j , Suit.clubs);
Group.add(Clubs);
//Clubs.toString()
}
for(int j = 1; j <= 13; j++)
{
Diamonds = new Card(j , Suit.diamonds);
Group.add(Diamonds);
}
/* for(int k = 0; k < 52; k++)
{
System.out.println(Deck.get(k));
}*/
}
public void add(Card c)
{
Last = c;
Group.add©;
}
public void add(CardGroup set )
{
for(int i = 0; i < Group.size(); i++)
{
Group.add(set);
}
}
public int count()
{
return Group.size();
}
public void get(int index)
{
// return Group.get(index); of type Card
}
public void getLast()
{
//return Card type
}
public Card draw()
{
return null;
/* int Random = (int)Math.random() * 52 + 1;
if(Random > Deck.size()) Random = Random - R;
Deck.remove(Random);
Group.add(Deck.get(Random));
R++;
return Deck.get(Random);*/
}
}
This post has been edited by Seraneth: 01 March 2009 - 11:21 PM

New Topic/Question
Reply




MultiQuote





|