well. i'm a total noob here, so bear with me please.
This is what I'm trying to do:
I want a playerCard class, which will represent a playing card.
I wand a deck class, which will represent a deck, and consist of
a given number of playerCards, plus some other variables, which I don't need arrays of.
so this is the abbreviated playerCard class:
Code:
class playerCard
{
int player_value, id;
int current_value, side, position;
String name, attrib, type;
boolean inDeck, inHand, discarded;
playerCard()
{
attrib="none";
player_value=0;
position=0;
type="none";
name="NONAME";
current_value=0;
side=0;
position=0;
inHand=false;
inDeck=false;
discarded=false;
}
void discard()
{
inHand=false;
inDeck=false;
discarded=true;
}
}
and this is what I'd like the deck class to be:
Code:class deck extends playerCard
{
int card_number;
int position;
int cards_now;
boolean shuffled;
boolean played;
boolean empty;
boolean full;
deck(int num)
{
card_number=num;
playerCard [] newCards=new playerCard[card_number];
shuffled=false; played=false; empty=false; full=true;
for (int i=1; i<=card_number; i++)
{
card[i].discard();
}
}
}
This, of course doesn't work. I get null pointer errors everywhere.
I'm really new to OOP. I just took up programming again after many years, so I don't really know if a thing like this can be done in such a way.
The result I'm trying to get is that when you call the deck class, it takes the NUM parameter and dimensions the array of playerCards inside it accordingly.
Any help would be greatly appreciated. Thx.