Hello im quite new to java and have been writing this game for my computer science class. ive been getting this illegal start of expression error on line 215 which is my 2nd public class dice extends applet and can not figure out how to fix it. ive tried moving around brackets but it still gives me the error heres my code.

import java.awt.*;
import java.applet.*;
import java.util.Random;

public class dice extends Applet
{


    Rectangle yes = new Rectangle (455,255,65,65);
    Rectangle no = new Rectangle (530,255,65,65);
    Rectangle chip5 = new Rectangle (560,510,75,75);
    Rectangle chip10 = new Rectangle (640,510,75,75);
    Rectangle chip15 = new Rectangle (720,510,75,75);
    Rectangle roll = new Rectangle (290,490,100,100);

    int numclicks = 0;
    int dice1 = 0;
    int dice2 = 0;
    int dice1=d.getDiceValue1(g);
    int dice2=d.getDiceValue2(g);   
    int dice1,dice2;
    int gameOn;
     int dicesum=dice1+dice2;

     integer bank = 500;
     integer betamount;
     integer point;

     boolean gameOn;
     boolean rolling;
     boolean win;
     boolean lose;
     boolean yessing;
     boolean no;

     boolean inYes,inNo,bet5,bet10,bet25;

    integer sum;

    public void init()
    {
        inYes = inNo = false;
        bet5 = bet10 = bet25 = rolling = false;
    }



    public void paint(Graphics g); 
    {
     drawdice d= new drawdice (g);
     drawboard b = new drawboard (g);
     gameOn = 1;
     if(inYes)  
    {
        b.placeyourbet(g);
    }
    else if(inNo)
    {
        b.thanksforplaying(g);
        gameOn=0;
    }
    if(bet5==true)
    {   
        betamount+=5;
        g.setColor(Color.black);
        g.drawString("Amount -->>" + betamount.toString(),480,450);
        g.setColor(Color.white);
        g.fillRect(o,200,470,300);
        g.setColor(Color.black);    
        g.setFont(new Font("TimesRoman",Font.BOLD,20));
        g.drawString("Click roll when ready",175,175);

    }
    if(bet10==true)
    {
        betamount+=10;
        g.setColor(Color.black);
        g.drawString("Amount -->>" + betamount.toString(),480,450);
        g.setColor(Color.white);
        g.fillRect(0,200,470,300);
        g.setColor(Color.black);
        g.setFont(new Font("TimesRoman",Font.BOLD,20));
        g.drawString("Click roll when ready",175,175);  
    }
    if(bet25==true)
    {
        betamount+=25;
        g.setColor(Color.black);
        g.drawString("Amount -->>" + betamount.toString(),480,450);
        g.setColor(Color.white);
        g.fillRect(0,200,470,300);
        g.setColor(Color.black);
        g.setFont(new Font("TimesRoman",Font.BOLD,20));
        g.drawString("Click roll when ready",175,175);
    }
    // game starts here
    if(rolling && gameOn ==1 && numclicks == 1)
    {
        g.setColor(Color.black);
        g.drawString("Amount -->" + betAmount. toString(),480,450);
        g.setColor(Color.blue);
        g.fillRect(0,200,470,300);
        g.setColot(Color.black);
        g.setFont(new Font("TimesRoman",Font.BOLD,20));
        g.drawString("Cmon winner winner!",50,280);


    }
    //dice roll
    dice1 = d.getDiceValue1 (g);
    dice2 = d.getDiceValue2 (g);
    diceSum = dice1 + dice2;

    if(dicesum == 7 || diceSum == 11)
    {
        rolling = false;
        bank += betAmount;
        gameOn = 0;
        g.setColor(Color.blue);
        g.fillRect(0,200,470,300);
        g.setColor(Color.black);
        g.setFont(new Font("Courier" ,Font.BOLD,20));
        g.drawString("winner winner chicken dinner! click [Yes] to continue",50,280);
        theBank(g);
    }
    else if(diceSum == 2|| diceSum == 3 || diceSum == 12)
    {
        rolling = false;
        bank-= betAmount;
        gameOn = 0;
        g.setColor(Color.blue);
        g.fillRect(0,200,470,300);
        g.setColor(Color.black);
        g.drawString("Sorry you lose...Click [Yes] to comtinue",50,280);
        theBank(g);
    }           
    else
    {
        rolling = true;
        point = diceSum;
        g.setColor(Color.black);
        g.drawString("Your point is" + point.toString(),500,180);
        gameOn +=1;
        numClicks = 1;


    }
    if(numClicks >1)
    {
        dice1 = d.getDiceValue1 (g);
        dice2 = d.getDiceValue2 (g);
        diceSum = dice1+dice2;
    if(diceSum == point)
    {
        gameOn = 0;
        rolling = false;
        bank +=betAmount;
        g.setColor(Color.blue);
        g.fillRect(0,200,470,300);
        g.setColor(Color.black);
        g.setFont(new Font("Courier",Font.BOLD,20));
        g.drawString("winner winner chicken dinner!click[Yes] to continue",50,280);
        theBank(g);
    }
    else if(diceSum == 7)
    {
        gameOn = 0;
        rolling = false;
        bank -=betAmount;
        g.setColor(Color.blue);
        g.fillRect(0,200,470,300);
        g.setColor(Color.black);
        g.setFont(new Font("Courier",Font.BOLD,20));
        g.drawString("You lose sorry click [Yes] to continue",50,280);
        theBank(g);
    }
    else
    {
        rolling = true;
        gameOn = 1;
        g.setColor(Color.blue);
        g.fillRect(0,200,470,300);
        g.setColor(Color.black);
        g.setFont(new Font("Courier",Font.BOLD,20));
        g.drawString("Click [Roll] to continue",50,280);
        g.setColor(Color.black);
        g.drawString("Your point is" + point.toString(),500,180);
    }







    {
        drawBoard b = new drawBoard(g);
        b.background(g);
        b.yesno(g);
        b.chips(g);
        b.roll(g);
        b.bank(g);
        drawDice d = new drawDice(g);
        d.getDiceValue1(g);
        d.getDiceValue2(g);
        // call dice methods here

    }


}

()

public class dice extends Applet
{




    public int getDiceValue1(Graphics g)
    {
        int dice1 = rand.nextInt(6) + 1;
        switch(dice1)
        {
            case 1 : leftDice1(g);break;
            case 2 : leftDice2(g);break;
            case 3 : leftDice3(g);break;
            case 4 : leftDice4(g);break;
            case 5 : leftDice5(g);break;
            case 6 : leftDice6(g);break;
        }

        return dice1;   
    }

    public int getDiceValue2(Graphics g)
    {
        int dice2 = rand.nextInt(6) + 1;
        switch(dice2)
        {
            case 1 : rightDice1(g);break;
            case 2 : rightDice2(g);break;
            case 3 : rightDice3(g);break;
            case 4 : rightDice4(g);break;
            case 5 : rightDice5(g);break;
            case 6 : rightDice6(g);break;
        }

        return dice2;
    }



   class drawBoard
   {
    public drawBoard(Graphics g)
    {
    }
    public void background(Graphics g)
    {
        g.setColor(Color.blue);
        g.fillRect(0,0,800,600);
    }
    public void yesno(Graphics g)
    {
        g.setColor(Color.black);
        g.fillRect(450,250,150,75);
        g.setColor(Color.white);
        g.fillRect(455,255,65,65);
        g.fillRect(530,255,65,65);
        g.setColor(Color.black);
        g.setFont(new Font("Courier",Font.BOLD,25));
        g.drawString("Yes.",460,295);
        g.drawString("No.", 540,295);
        g.drawString("Would you like to play?",50,295);
    }
    public void chips(Graphics g)
    {
        g.setColor(Color.red);
        g.fillOval(560,510,75,75);
        g.setColor(Color.yellow);
        g.fillOval(640,510,75,75);
        g.setColor(Color.green);
        g.fillOval(720,510,75,75);
        g.setColor(Color.black);
        g.drawOval(560,510,75,75);
        g.drawOval(640,510,75,75);
        g.drawOval(720,510,75,75);
        g.drawOval(565,515,65,65);
        g.drawOval(645,515,65,65);
        g.drawOval(725,515,65,65);
        g.setFont(new Font("Courier",Font.BOLD,20));
        g.drawString("$5",585,555);
        g.drawString("$10",660,555);
        g.drawString("$25",740,555);
    }
    public void roll(Graphics g)
    {
        g.setColor(Color.white);
        g.fillRect(290,490,100,100);
        g.setColor(Color.black);
        g.drawRect(290,490,100,100);
        g.setFont(new Font("Courier",Font.BOLD,30));
        g.drawString("Roll.",300,550);
    }
    public void theBank(Graphics g)
    {
    g.setFont(new Font("Courier",Font.BOLD,20));
    g.drawString("Click here to roll ===>",30,540);
    g.setColor(Color.black);
    g.fillRoundrect(390,510,50,10,10);

    }

   class drawDice{

    public drawDice(Graphics g)
    {
    }

    // Create your dice here
    public void leftDice1(Graphics g)
    {
        g.setColor(Color.black);
        g.fillRect(25,25,100,100);
        g.setColor(Color.white);
        g.fillOval(65,65,20,20);
    }
    public void rightDice1(Graphics g)
    {
        g.setColor(Color.black);
        g.fillRect(150,25,100,100);
        g.setColor(Color.white);
        g.fillOval(190,65,20,20);
    }
    public void leftDice2(Graphics g)
    {
        g.setColor(Color.black);
        g.fillRect(25,25,100,100);
        g.setColor(Color.white);
        g.fillOval(40,40,20,20);
        g.fillOval(90,90,20,20);
    }
    public void rightDice2(Graphics g)
    {
        g.setColor(Color.black);
        g.fillRect(150,25,100,100);
        g.setColor(Color.white);
        g.fillOval(165,40,20,20);
        g.fillOval(215,90,20,20);
    }
    public void leftDice3(Graphics g)
    {
        g.setColor(Color.black);
        g.fillRect(25,25,100,100);
        g.setColor(Color.white);
        g.fillOval(90,40,20,20);
        g.fillOval(65,65,20,20);
        g.fillOval(40,90,20,20);
    }
    public void rightDice3(Graphics g)
    {
        g.setColor(Color.black);
        g.fillRect(150,25,100,100);
        g.setColor(Color.white);
        g.fillOval(215,40,20,20);
        g.fillOval(190,65,20,20);
        g.fillOval(165,90,20,20);
    }
    public void leftDice4(Graphics g)
    {
        g.setColor(Color.black);
        g.fillRect(25,25,100,100);
        g.setColor(Color.white);
        g.fillOval(40,40,20,20);
        g.fillOval(90,90,20,20);
        g.fillOval(90,40,20,20);
        g.fillOval(40,90,20,20);
    }
    public void rightDice4(Graphics g)
    {
        g.setColor(Color.black);
        g.fillRect(150,25,100,100);
        g.setColor(Color.white);
        g.fillOval(165,40,20,20);
        g.fillOval(215,90,20,20);
        g.fillOval(215,40,20,20);
        g.fillOval(165,90,20,20);
    }
    public void leftDice5(Graphics g)
    {   
        g.setColor(Color.black);
        g.fillRect(25,25,100,100);
        g.setColor(Color.white);
        g.fillOval(40,40,20,20);
        g.fillOval(90,90,20,20);
        g.fillOval(90,40,20,20);
        g.fillOval(40,90,20,20);
        g.fillOval(65,65,20,20);
    }
    public void rightDice5(Graphics g)
    {
        g.setColor(Color.black);
        g.fillRect(150,25,100,100);
        g.setColor(Color.white);
        g.fillOval(165,40,20,20);
        g.fillOval(215,90,20,20);
        g.fillOval(215,40,20,20);
        g.fillOval(165,90,20,20);
        g.fillOval(190,65,20,20);
    }
    public void leftDice6(Graphics g)
    {
        g.setColor(Color.black);
        g.fillRect(25,25,100,100);
        g.setColor(Color.white);
        g.fillOval(40,40,20,20);
        g.fillOval(90,90,20,20);
        g.fillOval(90,40,20,20);
        g.fillOval(40,90,20,20);
        g.fillOval(40,65,20,20);
        g.fillOval(90,65,20,20);
    }
    public void rightDice6(Graphics g)
    {
        g.setColor(Color.black);
        g.fillRect(150,25,100,100);
        g.setColor(Color.white);
        g.fillOval(165,40,20,20);
        g.fillOval(215,90,20,20);
        g.fillOval(215,40,20,20);
        g.fillOval(165,90,20,20);
        g.fillOval(165,65,20,20);
        g.fillOval(215,65,20,20);
    }
} 


public boolean mouseDown (Event e,int x,int y)
{
    if(yes.inside(x,y))
    {
        inNo = bet5 = bet10 = bet25 = rolling = false;
        inYes = true;
        gameOn = 1;
        numclicks = 0;
        repaint();
    }
else if(no.inside(x,y))
{
    inYes = bet5 = bet10 = bet25 = rolling = false;
        inNo = true;
        gameOn = 0;
        numClicks = 0;
        repaint();      
}
if(chip5.inside(x,y))
{
    bet5 = true;
    bet10 = bet25 = inYes = inNo = rolling = false;
    numClicks = 0;
    repaint();
}
if(chip10.inside(x,y))
{
    bet10 = true;
    bet5 = bet25 = inYes = inNo = rolling = false;
    numClicks = 0;
    repaint();
}
if(chip25.inside(x,y))
{
    bet25 = true;
    bet5 = bet10 = inYes = inNo = rolling = false;
    numclicks = 0;
    repaint();

}
if(roll.inside(x.y))
{

        rolling = true;
        point = 0;
        gameOn = false;
        dicesum = 0;
          numClicks++;
        repaint();  
}       
    return true;
}

}  }}

Edited 3 Years Ago by mike_2000_17: Fixed formatting

Every public class must be in a file of the same name. You cannot declare two public classes in the same java file.

masijade has solved your problem. Every public class must be saved in separate file and the name of file must be same as public class.

PS: You post dice class twice. - Isn't it?

masijade has solved your problem. Every public class must be saved in separate file and the name of file must be same as public class.

PS: You post dice class twice. - Isn't it?

This was so very helpful, especially after the long, over-detailed post of masijade that still left so many things ambiguous and in the open to be explained.

Thank you.

You forgot to use sarcasm tags ;)

Someone is scratching their head trying to figure that last post out, I'll bet. heh

This article has been dead for over six months. Start a new discussion instead.