I swear, this is the last one for awhile. However, one more bug is stopping me.
So, I'm trying to call this newGame file. In short, the newGame will generate 5 random cards to each of the 4 players. I have one array controlling this, using 3 dimensions to keep track of each card. (User, Card Number, Suite Number) I know, probably not the easiest way to do this, but it's how I'm attempting.
Anyways, all I'm trying to do is to pass the grab the return array, which for whatever reason, I cannot seem to get.
Play.java
public void newGameMethod() //starts game
{
newGame start = new newGame();
cards = start.deal(); //works when this line is commented out...
System.out.println("test");
}
When I comment out "cards = start.deal();", the println works.
newGame.java
import java.util.Random;
public class newGame
{
public static int[][][] deal()
{
Random generator = new Random();
int[][][] cards = new int[4][5][4]; //Person, Card, Suit
<!--SNIP-->
return cards;
}
}
What am I doing wrong where I can't grab the array from newGame.
Thanks for the help. I know, this one is just me missing something so simple, I know it.
Question
Hendrick
I swear, this is the last one for awhile. However, one more bug is stopping me.
So, I'm trying to call this newGame file. In short, the newGame will generate 5 random cards to each of the 4 players. I have one array controlling this, using 3 dimensions to keep track of each card. (User, Card Number, Suite Number) I know, probably not the easiest way to do this, but it's how I'm attempting.
Anyways, all I'm trying to do is to pass the grab the return array, which for whatever reason, I cannot seem to get.
Play.java
public void newGameMethod() //starts game { newGame start = new newGame(); cards = start.deal(); //works when this line is commented out... System.out.println("test"); }When I comment out "cards = start.deal();", the println works.
newGame.java
import java.util.Random; public class newGame { public static int[][][] deal() { Random generator = new Random(); int[][][] cards = new int[4][5][4]; //Person, Card, Suit <!--SNIP--> return cards; } }What am I doing wrong where I can't grab the array from newGame.
Thanks for the help. I know, this one is just me missing something so simple, I know it.
Link to comment
Share on other sites
18 answers to this question
Recommended Posts