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 google.problems;

import google.loader.Challenge;
import google.loader.ChallengeReader;

import java.util.ArrayList;
import java.util.List;


public abstract class AbstractReader implements ChallengeReader {

	private String[] lines;
	private List<Challenge> challenges;
	private int actualLine;

	public AbstractReader(){
		challenges = new ArrayList<Challenge>();
	}
	
	
	protected void setLines(String[] input) {
		lines=input;
	}

	protected String[] getLines(){
		return lines;
	}
	
	protected int getNumberOfChallenges() {
		return Integer.parseInt(lines[0]);
	}
	
	@Override
	public List<Challenge> createChallenges(String[] input) {
		setLines(input);
		readChallenges();
		return challenges;
	}

	private void readChallenges() {
		int numOfChallanges = getNumberOfChallenges();
		setActualLine(1);
		actualLine = 1;
		for(int i=1;i<=numOfChallanges; i++){
			challenges.add(createChallenge(i));
		}
	}
	
	protected int[] asInt(String values) {
		String[] split = values.split(" ");
		int res [] = new int[split.length];
		for(int i=0;i<split.length;i++){
			res[i]=Integer.parseInt(split[i]);
		}
		return res;
	}

	protected List<Integer> asIntList(String values) {
		List<Integer> res = new ArrayList<Integer>();
		for(int i : asInt(values)){
			res.add(i);
		}
		return res;
	}
	

	protected abstract Challenge createChallenge(int i) ;
	
	protected void setActualLine(int i) {
		actualLine =i;
	}
	protected int getActualLine(){
		return actualLine;
	}
	
}
