mardi 3 octobre 2017

Java prediction error Random not working?

Hello I have been working on a program that predicts numbers. I have went through the code several times now and edited it. For some reason teamOneScored is ALWAYS higher than teamTwoScored. This does not make any sense to me.

What is the error that is occurring?

    int[] teamOneScored = new int[99];
    int[] teamTwoScored = new int[99];
    int[] oneShotOn = new int[99];
    int[] twoShotOn = new int[99];
    int[] OnePossession = new int[99];
    int[] TwoPossession = new int[99];

    for(int i = 0; i < depth; i++)
    {
        for(int x = 0; firstShotCount >= x; x++)
        {
            Random random = new Random();
            int shot = random.nextInt(10 - 1 + 1) + 1;

            if (shot > 8)
            {
                teamOneScored[i] = teamOneScored[i] + 1;
            }

            if (shot > 4)
            {
                oneShotOn[i] = oneShotOn[i] + 1;
            }
        }

        for(int y = 0; secondShotCount >= y; y++)
        {
            Random random = new Random();
            int shot = random.nextInt(10 - 1 + 1) + 1;

            if (shot > 8)
            {
                teamTwoScored[i] = teamTwoScored[i] + 1;
            }

            if (shot > 4)
            {
                twoShotOn[i] = twoShotOn[i] + 1;
            }
        }
        System.out.println(teamOneScored[i] + ":" + teamTwoScored[i]);
    }




Aucun commentaire:

Enregistrer un commentaire