dimanche 19 mars 2017

For loop/If statement not being reached

Been trying to get this code to work with WindowBuilder, but whenever I run the application and click the button, it returns with a blank label when I try to set the text pane in the if-statement, or it returns 0 if I try to set the text pane after the main for loop. Any ideas?

JFrame frame;
    JButton btnRoll = new JButton("Roll");
    int dieStr = 0;
    int dieDex = 0;
    int dieCon = 0;
    int dieInt = 0;
    int dieWis = 0;
    int dieCha = 0;
    int dieGold = 0;
    int[] statDice = new int[] {0, 1, 2, 3};

btnRoll.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {



                    for(int a=0;a>6;a++){

                        for(int i=0;i>4;i++){
                            statDice[i] = ((int)(Math.random()*6) + 1); // six sided dice roll
                            }//end dice rolling
                        Arrays.sort(statDice); //sorts the array from lowest to highest
                        if(a==0){
                            dieStr = statDice[1]+statDice[2]+statDice[3]; //adds the three highest dice rolls to make the stat
                            textPaneStrength.setText(Integer.toString(dieStr));
                        }
                        else if(a==1)
                            dieDex = statDice[1]+statDice[2]+statDice[3];
                        else if(a==2)
                            dieCon = statDice[1]+statDice[2]+statDice[3];
                        else if(a==3)
                            dieInt = statDice[1]+statDice[2]+statDice[3];
                        else if(a==4)
                            dieWis = statDice[1]+statDice[2]+statDice[3];
                        else if (a==5)
                            dieCha = statDice[1]+statDice[2]+statDice[3];
                    }///end stat generation


                    textPaneDexterity.setText(Integer.toString(dieDex));
                    for(int x=0;x>5;x++){
                        dieGold = ((int)(Math.random()*4) + 1)*10 + dieGold; //rolls a 4-sided die 5 times, multiplies by ten and the total is your starting gold

                    }//end gold generation
                    textPaneStartingGold.setText(Integer.toString(dieGold));

Aucun commentaire:

Enregistrer un commentaire