vendredi 4 août 2017

How is this 'not a statement'

I have some code and I can't figure out where I went wrong. I would like some help with this.
My code:

import java.util.Random;
import java.util.Arrays;
import java.util.ArrayList;

public class main {  
  public static void main(String args[]) {
    Random as = new Random();
    ArrayList<String> teams = new ArrayList<>(Arrays.asList("Red", "Green", "Blue",
                                                       "Yellow", "Orange", "Purple")); 
    System.out.println("team1: " + teams.remove(as.nextInt(teams.size())));
    System.out.println("team2: " + teams.remove(as.nextInt(teams.size())));
    System.out.println("team3: " + teams.remove(as.nextInt(teams.size())));
    System.out.println("team4: " + teams.remove(as.nextInt(teams.size())));
    System.out.println("team5: " + teams.remove(as.nextInt(teams.size())));
    System.out.println("team6: " + teams.remove(as.nextInt(teams.size())));
    System.out.println("team4 v team2");
    System.out.println("team5 v team1");
    System.out.println("team3 v team6");
    int t1 = as.nextInt(15);
    int t2 = as.nextInt(15);
    int t3 = as.nextInt(15);
    int t4 = as.nextInt(15);
    int t5 = as.nextInt(15);
    int t6 = as.nextInt(15);
    System.out.println("Game 1 score: " + t2 + " to " + t4);
    System.out.println("Game 2 score: " + t5 + " to " + t1);
    System.out.println("Game 3 score: " + t3 + " to " + t6);
    ArrayList<String> rankings = new ArrayList<>(Arrays.asList("Red", "Green", "Blue",
                                                       "Yellow", "Orange", "Purple"));
    System.out.println("Rankings:");

The lines that give me trouble:

    System.out.println("1. " + rankings.remove(as.nextInt(rankings.size()))) + t1 + " points";
    System.out.println("2. " + rankings.remove(as.nextInt(rankings.size()))) + t2 + " points";
    System.out.println("3. " + rankings.remove(as.nextInt(rankings.size()))) + t3 + " points";
    System.out.println("4. " + rankings.remove(as.nextInt(rankings.size()))) + t4 + " points";
    System.out.println("5. " + rankings.remove(as.nextInt(rankings.size()))) + t5 + " points";
    System.out.println("6. " + rankings.remove(as.nextInt(rankings.size()))) + t6 + " points";
  }
}

The code shown that I seperated is the only part that gives me the error. All the error says is: Error Not A Statement and I can't figure out what I did wrong with this code. Any help is appreciated.




Aucun commentaire:

Enregistrer un commentaire