mercredi 20 septembre 2017

Why is random not doing random [on hold]

I made a random number generator, three of them, and for some reason the first two are always the same number. I also made an if else if statement, but for some reason the second doesn't do anything, and the first and third don't work.
The if statements and ints are here:

int lvlone = rn.nextInt(98) + 1;
int lvltwo = rn.nextInt(98) + 1;
int lvlthree = rn.nextInt(98) + 1;
int decone = 1;
int dectwo = 1;
int decthree = 1;



if (decone == 1) {
    if(lvlone < 55) g.setColor(new Color(185, 122, 87));
    if(lvlone > 54 && lvlone < 75) g.setColor(Color.gray);
    if(lvlone > 74 && lvlone < 95) g.setColor(Color.yellow);
    if(lvlone > 94) g.setColor(Color.white);
    g.fillRect(50, 50, 50, 100);
    g.setColor(Color.black);
    g.drawString(st, 60, 60);
}
if (dectwo == 1) {
    if(lvltwo <= 54) g.setColor(new Color(185, 122, 87));
    if(lvltwo >= 55 && lvltwo <= 74) g.setColor(Color.gray);
    if(lvltwo >= 75 && lvltwo <= 94) g.setColor(Color.yellow);
    if(lvltwo >= 95) g.setColor(Color.white);
    g.setColor(Color.black);
    }
if (decthree == 1) {
    if(lvlthree <= 54) g.setColor(new Color(185, 122, 87));
    if(lvlthree <= 55 && lvlthree < 75) g.setColor(Color.gray);
    if(lvlthree <= 75 && lvlthree < 95) g.setColor(Color.yellow);
    if(lvlthree >= 95) g.setColor(Color.white);
    g.setColor(new Color(185, 122, 87));
    g.fillRect(250, 50, 50, 100);
    g.setColor(Color.black);
    }
    }
}

To get more in depth, my first and third ones just randomly choose a color, while I only get the number from the second.




Aucun commentaire:

Enregistrer un commentaire