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 tr0llhoehle.cakemix.utility.googleCodeJam;

import java.text.ParseException;

/**
 * This class is a base class for all concrete problems. It is used to define
 * some methods necessary for the IOManager to work. It is crucial that the
 * addValue-Method gets extended and called (super.addValue(o)) by the extending
 * class.
 * 
 * @author Cakemix
 * @see IOManager
 * @see Solver
 */
public abstract class Problem {

    protected SupportedTypes[] types;
    protected int cntr = 0;
    protected boolean isInitialised = false;

    /**
     * Returns an array of SupportedTypes which define exactly what data is
     * stored in this problem.
     * 
     * The attribute "types" needs to be initialized in the constructor of the
     * extending class.
     * 
     * @return An array of SupportedTypes which define exactly what data is
     *         stored in this problem.
     * @see SupportedTypes
     */
    public SupportedTypes[] getTypes() {
	return types;
    }

    public void addValue(Object o) throws ParseException {
	if (!isInitialised) {
	    cntr++;
	    isInitialised = (cntr == types.length);
	} else {
	    throw new ParseException("Tried to add another value to this Problem even though all values are set.", cntr);
	}
    }
}
