jeudi 31 décembre 2015

I'm Having trouble adding values to a ArrayList with methods

So basically my problem is in this program which i will explain better after i put it in

    package learning;
//This class has an important method that i have been working on called Dice6 don't delete

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class GameBoard {

    public static void main(String[] args) {

        System.out.println("Welcome To The Gameboard");
        System.out.println("What is your name player 1?");

        Scanner Scan = new Scanner(System.in);

        String ScanResult1 = Scan.nextLine();

        System.out.println("Well... " + ScanResult1 + " This is the Board");

        System.out.println("~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~|");// Don't Question its
                                                        // placement its weird,
                                                        // but it works
        System.out.println("               |");
        System.out.println("               |~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~");

        System.out.println("Lets start with a Dice Roll");

        System.out.println(ScanResult1 + " Got a Roll of " + Dice6(10));

        Scan.close();

    }

    static int Dice6(int y) {
        ArrayList<Integer> Dice = new ArrayList<Integer>();
        Dice.add(1);
        Dice.add(2);
        Dice.add(3);
        Dice.add(4);
        Dice.add(5);
        Dice.add(6);


        int DiceAmount = Dice.size();
        while (DiceAmount != 6) {
            DiceAmount= DiceAmount - 1;
            Dice.add(Dice.size() + 1);
        }
        Collections.shuffle(Dice);
        Collections.shuffle(Dice);
        Integer DiceResult = Dice.get(3);
        return DiceResult;
    }

}

Ok so the problem I'm having is from System.out.println(ScanResult1 + " Got a Roll of " + Dice6(10)); to the bottom of the program basically I'm trying to add Array values in the ArrayList by using the parameter 10.... what suppose to happen is there is suppose to be 10 values in the ArrayList depending on what i put in the parameter....I've tried a lot of things and done a lot of fixing, i ever did a for(blank x : Dice) to show all values and 10 didn't come up only the original 6....if any body has any idea how to solve this please tell me

Aucun commentaire:

Enregistrer un commentaire