package com.menzus.gcj._2012.qualification.c;

import com.menzus.gcj.common.InputBlockParser;
import com.menzus.gcj.common.OutputProducer;
import com.menzus.gcj.common.impl.AbstractProcessorFactory;

public class CProcessorFactory extends AbstractProcessorFactory<CInput, COutputEntry> {
    public CProcessorFactory(String inputFileName) {
	super(inputFileName);
    }

    @Override
    protected InputBlockParser<CInput> createInputBlockParser() {
	return new CInputBlockParser();
    }

    @Override
    protected OutputProducer<CInput, COutputEntry> createOutputProducer() {
	return new COutputProducer();
    }
}

package be.mokarea.gcj.common;

import java.io.PrintWriter;

public abstract class Transformation<T extends TestCase> {
	private TestCaseReader<T> caseReader;
	private final PrintWriter outputWriter;

	public Transformation(TestCaseReader<T> caseReader, PrintWriter outputWriter) {
		this.caseReader = caseReader;
		this.outputWriter = outputWriter;
	}

	public void transformAll() throws Exception {
		T testCase = caseReader.nextCase();
		while (testCase != null) {
			outputWriter.println(transform(testCase));
			testCase = caseReader.nextCase();
		};

	}
	
	protected abstract String transform(T testCase);
}
