Hello. I have a program:
And how can I change turn number in random?package Dice; import java.util.Scanner; public class Dice { int game; String [] players; int [] Wonthenumberofturns; int esk; int [] er; int [] turnswinners; private Scanner scan; private Scanner scan2; private Scanner scan3; public void Players(){ scan = new Scanner(System.in); System.out.println("Insert how many players play in game:"); int game = scan.nextInt(); scan.nextLine(); players = new String [game]; Wonthenumberofturns = new int [game]; for(int i = 0; i < game; i++){ System.out.println("Insert player number" + Integer.toString(i+1)); players[i] = scan.nextLine(); Wonthenumberofturns[i] = 0; } //scan.close(); } public void Turnnumber(){ scan2 = new Scanner(System.in); System.out.println("Enter the desired number of turns"); game = scan2.nextInt(); scan2.nextLine(); er = new int [game]; turnswinners = new int [game]; } public void Go(int Gonumber){ int Biggest = 0; int Record = 0; scan3 = new Scanner(System.in); for(int i = 0; i < game; i++){ System.out.println("Enter the number of players rolling the" + players[i]); int Rezult = scan3.nextInt(); scan3.nextLine(); if (Rezult > Biggest){ Biggest = Rezult; Record = i; } } System.out.println("Turn win the player" + players[Record]); turnswinners[Gonumber] = Record; er[Gonumber] = Biggest; Wonthenumberofturns[Record]++; } public void Winner(){ for(int i = 0; i < game; i++){ int winnernumber = turnswinners[i]; int taskai = er[i]; System.out.println("Turn" + Integer.toString(i+1) + "won" + players[winnernumber]); System.out.println("collected" + Integer.toString(taskai) + "points"); } int winners = 0; int winner = 0; for (int i = 0; i < game; i++) { if (Wonthenumberofturns[i] > winners) { winners =Wonthenumberofturns[i]; winner = i; } } System.out.println("Game winner" + players[winner]); } public void zaid(){ Players(); Turnnumber(); for(int i = 0; i < game; i++){ Go(i); } Winner(); } }
I have a code: