package scores;

import java.util.ArrayList;
import java.util.Random;
import java.util.Scanner;

import utils.Parser;

/**
 * Main class for running the application
 * @author Johan Brunet, Julien Gallego
 *
 */
public class TestHighScore2 {
	/**
	 * The ThingSpeak URL to connect to in order to retrieve data
	 */
	public static final String THINGSPEAK_URL = "https://api.thingspeak.com/channels/109692/feeds.csv";
	
	/**
	 * Main of the application
	 * @param args some arguments
	 */
	public static void main(String[] args) {
		String playerName;
		int score;
		HighScore2 highScore = new HighScore1(THINGSPEAK_URL);
		BestPlayer[] top;
		
		Scanner scan = new Scanner(System.in);
		System.out.println("> Please enter a player name");
		if (scan.hasNext()) {
			playerName = scan.nextLine();
		}
		else {
			playerName = "default";
		}
		scan.close();
		ArrayList<String> dataToParse = new ArrayList<String>(highScore.getScores());
		ArrayList<Integer> scores = new ArrayList<Integer>();
		for (String s : dataToParse) {
			scores.add(Parser.parseScore(s));
		}
		score = scores.get(getRandInt(scores.size()));
		
		top=highScore(dataToParse);
		
		int i = 0;
		for (BestPlayer b : top) {
			System.out.println("Score " + i + " : joueur " + b.player + " : " + b.score);
			i++;
		}
		
		System.out.println("Player : " + playerName);
		System.out.println("Score : " + score);
	}
	
	/**
	 * Method to get a random integer between 0 and the specified bound
	 * @param bound maximum value of the random integer
	 * @return a random integer between 0 and the bound
	 */
	private static int getRandInt(int bound) {
		Random rand = new Random();
		return (int)(rand.nextInt(bound));
	}
}
@@ -33,97 +33,16 @@
 til.
-ArrayList;%0D%0Aimport java.util.Random;%0D%0Aimport java.util.Scanner;%0D%0A%0D%0Aimport utils.Parser;%0D%0A
+Scanner;
 %0D%0A/*
@@ -491,22 +491,8 @@
 e;%0D%0A
-%09%09int score;%0D%0A
 %09%09Hi
@@ -525,17 +525,17 @@
 ighScore
-1
+2
 (THINGSP
@@ -557,16 +557,17 @@
 stPlayer
+2
 %5B%5D top;%0D
@@ -738,362 +738,80 @@
 %0D%0A%09%09
-else %7B%0D%0A%09%09%09playerName = %22default%22;%0D%0A%09%09%7D%0D%0A%09%09scan.close();%0D%0A%09%09ArrayList%3CString%3E dataToParse = new ArrayList%3CString%3E(highScore.getScores());%0D%0A%09%09ArrayList%3CInteger%3E scores = new ArrayList%3CInteger%3E();%0D%0A%09%09for (String s : dataToParse) %7B%0D%0A%09%09%09scores.add(Parser.parseScore(s));%0D%0A%09%09%7D%0D%0A%09%09score = scores.get(getRandInt(scores.size()));%0D%0A%09%09%0D%0A%09%09top=highScore(dataToParse
+scan.close();%0D%0A%09%09%0D%0A%09%09top = highScore.tenBestScores(highScore.getScores()
 );%0D%0A
@@ -825,12 +825,8 @@
 nt i
- = 0
 ;%0D%0A%09
@@ -835,532 +835,124 @@
 or (
-BestPlayer b : top) %7B%0D%0A%09%09%09System.out.println(%22Score %22 + i + %22 : joueur %22 + b.player + %22 : %22 + b.score);%0D%0A%09%09%09i++;%0D%0A%09%09%7D%0D%0A%09%09%0D%0A%09%09System.out.println(%22Player : %22 + playerName);%0D%0A%09%09System.out.println(%22Score : %22 + score);%0D%0A%09%7D%0D%0A%09%0D%0A%09/**%0D%0A%09 * Method to get a random integer between 0 and the specified bound%0D%0A%09 * @param bound maximum value of the random integer%0D%0A%09 * @return a random integer between 0 and the bound%0D%0A%09 */%0D%0A%09private static int getRandInt(int bound) %7B%0D%0A%09%09Random rand = new Random
+i = 0; i %3C top.length; i++) %7B%0D%0A%09%09%09System.out.println(i + %22 - %22 + top%5Bi%5D.getName() + %22 : %22 + top%5Bi%5D.getScore
 ()
+)
 ;%0D%0A%09%09
-return (int)(rand.nextInt(bound));
+%7D
 %0D%0A%09%7D

Remove useless things