I am trying to do a classic round robin game which each of the player from 1-5 would get a random number but for each round that random number would add another random number and when the number reaches 11+ points it will show winner.
Here's what I've got so far. import java.util.Collections; import java.util.LinkedList;
public class RoundRobin {
public static void main(String[] args){
LinkedList<String> list = new LinkedList<String>();
int max = 11;
int min = 1;
int range = max - min + 1;
System.out.println("Round 1");
list.add("Player 1: ");
list.add("Player 2: ");
list.add("Player 3: ");
list.add("Player 4: ");
list.add("Player 5: ");
for(int i=0; i < list.size(); i++)
{
int rand = (int)(Math.random() * range) + min;
System.out.println(list.get(i) + rand);
}
System.out.println("");
System.out.println("Round 2");
for(int i=0; i < list.size(); i++)
{
int rand = (int)(Math.random() * range) + min;
System.out.println(list.get(i) + rand);
}
}
}
and the output goes like this (In the second round the value must be change to what was added in random):
Round 1
Player 1: 9
Player 2: 8
Player 3: 1
Player 4: 11
Player 5: 9
Round 2
Player 1: 3
Player 2: 6
Player 3: 5
Player 4: 10
Player 5: 9
The sample output is something like this:
Round 1
Player 1: 4
Player 2: 8
Player 3: 3
Player 4: 2
Player 5: 6
Round 2
Player 1: 7 //It randomly added 3
Player 2: 10 //randomly added 2
Player 3: 8
Player 4: 7
Player 5: 9
Aucun commentaire:
Enregistrer un commentaire