I've been working on an applet and, for some reason, it erroring out and not reading some of the variables..I guess the last one may be connected to the first set of errors, but I'm not sure. Thank you(: I would like to fix this.
import java.applet.Applet;
import java.awt.Graphics;
import java.awt.Image;
import java.util.Random;
public class Cards10 extends Applet
{
Image card1, card2, card3, card4, card5, card6, card7, card8, card9, card10, flipped;
public void init()
{
String deckCards[] = {"c1.gif", "c2.gif", "c3.gif", "c4.gif", "c5.gif", "c6.gif", "c7.gif", "c8.gif", "c9.gif", "c10.gif", "cj.gif", "ck.gif", "cq.gif", "s1.gif", "s2.gif", "s3.gif", "s4.gif", "s5.gif", "s6.gif", "s7.gif", "s8.gif", "s9.gif", "s10.gif", "sj.gif", "sk.gif", "sq.gif", "d1.gif", "d2.gif", "d3.gif", "d4.gif", "d5.gif", "d6.gif", "d7.gif", "d8.gif", "d9.gif", "d10.gif", "dj.gif", "dk.gif", "dq.gif", "h1.gif", "h2.gif", "h3.gif", "h4.gif", "h5.gif", "h6.gif", "h7.gif", "h8.gif", "h9.gif", "h10.gif", "hj.gif", "hk.gif", "hq.gif"};
for(int k = 0; k < 10; k++)
{
Random rand = new Random();
int r = rand.nextInt(52);
card(k) = getImage( getDocumentBase(), String.format("%ss.gif", deckCards[r]) ); //I know I'm using String.format wrong here..is there anyway I can get it to format a string and include the .gif as it is now or must I take the '.gif" out of my list and simply do %2s.gif or is there any other way to avoid that?
}
flipped = getImage(getDocumentBase(), "b1fv.gif");
}
public void paint(Graphics g)
{
g.drawImage(flipped, 10, 10, this);
for (int i = 1; i < 6; i++)
{
g.drawImage(card(k), 10 + (20*i), 10, this);
}
for (int j = 6; j < 11; j++) /*I know this shouldn't be here as it would draw each card j times (same for i)..fixed on mine but is there any way to do this without listing them all out?*/
{
g.drawImage(card(k), 10 + (20*j), 125, this);
}
}
public int shuffle(String [] deckCards)
{
for (int n = 0; n < 10; n++);
{
Random rand = new Random();
int r = rand.nextInt(52);
return r;
}
}
}
here are the errors:
Main.java:26: error: cannot find symbol
g.drawImage(card(k), 10 + (20*i), 10, this);
^
symbol: variable k
location: class Cards10
Main.java:30: error: cannot find symbol
g.drawImage(card(k), 10 + (20*j), 125, this);
^
symbol: variable k
location: class Cards10