"java.lang.StackOverflowError
at greenfoot.Actor.getClassImage(Actor.java:646)
at greenfoot.Actor.<init>(Actor.java:124)
at UpCard.<init>(UpCard.java:9)
at CardA.<init>(CardA.java:9)"
The last two repeat a BUNCH before stopping.
I was trying to make a random card image appear when clicked, and then for each card to have an answer. (I know that doesn't make much sense, but if you know what Quizlet is, it's sort of a quiz type of thing.... eh.)
I think the problem may lie in the code for UpCard and CardA (B-D as well)...
Here's the code for UpCard:
And CardA:
I have the same code in CardB-D.
This project is due tomorrow so if someone can help me asap, it'd be so much appreciated! :0
public void addCard(){
int n = Greenfoot.getRandomNumber(6);
if (n == 1){
getWorld().addObject(A, getX(), getY());
getWorld().removeObject(this);
}
else if (n == 2){
getWorld().addObject(B, getX(), getY());
getWorld().removeObject(this);
}
else if (n == 3){
getWorld().addObject(C, getX(), getY());
getWorld().removeObject(this);
}
else if (n == 4){
getWorld().addObject(D, getX(), getY());
getWorld().removeObject(this);
}
else if (n == 1){
getWorld().addObject(M, getX(), getY());
getWorld().removeObject(this);
}
}public void chooseCard(){
int i = Greenfoot.getRandomNumber(11);
GreenfootImage img = new GreenfootImage("CardA" + i + ".jpg");
setImage(img);
}

