package dancinggooglers;

import java.io.File;
import java.util.Scanner;

public class DanceScoreCalculator {


    public static void main(String[] args) {
        if(args.length <= 0 || args[0] == null) {
            System.out.println("You must enter a file to read");
            System.out.println("Usage: blah <filename>");
            System.exit(0);
        }

        File argFile = new File(args[0]);
        try {
            Scanner googleSpeakScanner = new Scanner(argFile);
            String firstLine = googleSpeakScanner.nextLine();
            Integer linesToScan = new Integer(firstLine);
            for(int i = 1; i <= linesToScan; i++) {
                String googleDancerLine = googleSpeakScanner.nextLine();
                DanceScoreCase danceCase = new DanceScoreCase(googleDancerLine);
                System.out.println(String.format("Case #%d: %d", i, danceCase.maxDancersThatCouldPass()));
            }
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }
}

package be.mokarea.gcj.googledancers;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.LineNumberReader;

import be.mokarea.gcj.common.TestCaseReader;

public class GoogleDancerTestCaseReader extends
		TestCaseReader<GoogleDancerTestCase> {
	private final LineNumberReader lineReader;
	private final int NUMBER_TEST_CASE;
	private int currentCaseNumber;
	
	public GoogleDancerTestCaseReader(InputStream inputStream) throws NumberFormatException, IOException {
		lineReader = new LineNumberReader(new InputStreamReader(inputStream));
		NUMBER_TEST_CASE = Integer.parseInt(lineReader.readLine());
		currentCaseNumber = 0;	}

	@Override
	public GoogleDancerTestCase nextCase() throws Exception {
		String line = lineReader.readLine();
		if (line != null) {
			currentCaseNumber++;
			String[] tokens = line.split(" ");
			final int numberOfGooglers = Integer.parseInt(tokens[0]);
			final int numberOfSurprisingTripletsOfScores = Integer.parseInt(tokens[1]);
			final int scoreLowerBoundary = Integer.parseInt(tokens[2]);
			
			final int scores[] = new int[numberOfGooglers];
			for (int i = 3, j = 0 ; i < tokens.length ; i++, j++) {
				scores[j] = Integer.parseInt(tokens[i]);
			}
			return new GoogleDancerTestCase(currentCaseNumber, numberOfGooglers, numberOfSurprisingTripletsOfScores, scoreLowerBoundary, scores);
		}
		return null;	}

	@Override
	public int getMaxCaseNumber() {
		return NUMBER_TEST_CASE;
	}

}
