I am taking AP Comp Sci and working on the lab "elevens". All I'm trying to do is instantiate an object of the "Deck" class, and my constructor is throwing a NullPointerError. After doing a print check, I found that the first index is being found correctly, it's the second that's throwing the error. What do I need to change in either my Deck class or my main method to fix this issue?
public Card(String cardRank, String cardSuit, int cardPointValue)
{
suit = cardSuit;
rank = cardRank;
pointValue = cardPointValue;
}
private ArrayList<Card> cards;
public Deck(String[] ranks, String[] suits, int[] values)
{
for(int i =0; i < suits.length; i++)
{
cards.add(new Card(ranks[i], suits[i], values[i]));
size++;
}
}
public static void main(String[] args)
{
String [] suits = new String [] {"Spades", "Hearts", "Diamonds"};
String [] ranks = new String [] {"Queen", "King", "Ace"};
int [] points = new int [] {10, 10, 11};
Deck deck = new Deck(ranks, suits, points);
}