samedi 3 mars 2018

How would I initialize multiple arrays with one declaration?

I know that I have to declare an array before initializing it. My issue is trying to declare an array and initialize it in two more places. I cannot initialize in those two places, but I have done so in one place. After that, I have to list the teams, as well as the wins and losses. How would I begin?

    boolean ne = true;
    int teams;
    int W = 0;
    int L = 0;
    Scanner Ball = new Scanner(System.in);

        do {
            System.out.println("1. Create League.");
            System.out.println("2. Look up Teams.");
            System.out.println("3. Mark Win.");
            System.out.println("4. Mark Loss.");
            System.out.println("5. Quit.");
            int dru = Ball.nextInt();
            String [] Dan;
            int[] San;
            if (dru == 1)
            {
                System.out.println("How many teams?");
                teams = Ball.nextInt();
                Dan = new String[teams];
                for (int i = 0; i< Dan.length; i++)
                {
                    System.out.println("The name of Team "+(i+1)+"?");
                    Dan[i]= Ball.next();
                }
            }
            if (dru == 3)
            {
                int[] San = new int[W];

                for (int i = 0; i < San.length; i++)
                {
                }
            }
            if (dru == 4)
            {
                int[] Sans = new int[L];

                for (int i = 0; i < San.length; i++)
                {
                }
            }
            if(dru == 2)
            {

                System.out.println("Team "+"W"+"L");

                for (int i = 0; i < L; i++)
                {
                System.out.println(Dan[i]+"  "+W+L);
                }
            }
            if (dru == 5 && ne == true)
            {
                ne = false;
                System.out.println("Goodbye.");
                    if (ne == false)
                        break;
            }
        } while (ne == true);

Aucun commentaire:

Enregistrer un commentaire