Complex data types in java -
i have designed data type called bingocard create random bingo card. i'm trying make bingocard array keep getting error on line: system.out.println(currentcard[i].tostring());
i'm wondering if i've created array correctly or doing wrong? in advance.
public class bingogame { private int[] counter; private boolean done = false; private int numofcards; private int fastestcard; public bingogame(int num){ numofcards = num; counter = new int[numofcards]; } public int play(){ for(int a=0;a<numofcards;a++){ counter[a] = 0; } bingocard[] currentcard = new bingocard[numofcards]; while(!done){ for(int i=0;i<numofcards;i++){ system.out.println("this current card:"); system.out.println(currentcard[i].tostring()); int currentnum = (int)(math.random() * 75) + 1; counter[i]++; currentcard[i].currentnumber(currentnum); currentcard[i].bingo(); if(currentcard[i].bingo()){ done = true; } fastestcard = i; } } return counter[fastestcard]; } }
elements in object
array null
default. need instantiate elements before attempting invoke methods
for (int = 0; < numofcards; i++) { currentcard[i] = new bingocard(); ... }