Ok
I would like to use Deck in a third class.
Deck myDeck = new Deck();
Then in paint I try
g.drawString("" + myDeck[1].suit, 50,50);
It says 'array required, but Deck found'
If I try
Deck[] myDeck = new Deck();
I get 'incompatable types'
I hate asking for help BUT I need the correct way to use(instantiate) a Deck object.
Thanks in advance
public class Card { public int rank; public String suit; } public class Deck { private int random = 0; private Card[] deck = new Card[52]; final String[] suit = {"hearts", "diamonds", "spades", "clubs"}; public Deck() { int cardNumber = 0; for(int suitNo = 0; suitNo < 4; suitNo++) { for(int rank = 1;rank < 14; rank++) { deck[cardNumber] = new Card(); deck[cardNumber].suit = suit[suitNo]; deck[cardNumber].rank = rank; cardNumber++; } } } }