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();
        }
    }
}

import java.io.*;
import java.util.ArrayList;


public class inpOutHandler {

	public testCase readInput(String fname, int linesInTestCase){
		testCase allCases;
		ArrayList<String> lineList = new ArrayList<String>();
		BufferedReader rd = null;
			try {
				rd = new BufferedReader(new FileReader(fname));
				while (true) {
					String line = rd.readLine();
					if (line == null) break;
					lineList.add(line);
				}
				rd.close();
			} catch (IOException ex) {
				System.out.println("Can't open that file.");
			} 
			//for(int i=0;i<lineList.size();i++)
				//System.out.println("<" + lineList.get(i) + ">");
			
		int N = Integer.parseInt(lineList.get(0));
			//int N=100;
		allCases = new testCase(N);
		int index=1;
		for(int i=0;i<N;i++){
			String tempS="";
			for(int j=0;j<linesInTestCase;j++){
				if(j==linesInTestCase-1){
				tempS += lineList.get(index++);
				}else{
					tempS += lineList.get(index++) +"\n";
				}
			}
			allCases.addCase(tempS);
		}
		return allCases;
	}
	
	public void createOutput(String fname, String content){
		try{
			  // Create file 
			  FileWriter fstream = new FileWriter(fname);
			  BufferedWriter out = new BufferedWriter(fstream);
			  out.write(content);
			  //Close the output stream
			  out.close();
			  }catch (Exception e){//Catch exception if any
			  System.err.println("Error: " + e.getMessage());
			  }
	}
}
