diff options
author | Eduardo Pedroni <ep625@york.ac.uk> | 2014-04-25 19:38:16 +0100 |
---|---|---|
committer | Eduardo Pedroni <ep625@york.ac.uk> | 2014-04-25 19:38:16 +0100 |
commit | b0c0698e5503c2506217117bf144fde31e6f6601 (patch) | |
tree | 11a6e20fb565f1e75fb25852e757e4a37e4c313b /src/jcgp/backend/parser/TestCaseParser.java | |
parent | 9ac2848be66c39acdc291dc3b48b91178acc1a05 (diff) |
Commented lots of packages.
Diffstat (limited to 'src/jcgp/backend/parser/TestCaseParser.java')
-rw-r--r-- | src/jcgp/backend/parser/TestCaseParser.java | 90 |
1 files changed, 0 insertions, 90 deletions
diff --git a/src/jcgp/backend/parser/TestCaseParser.java b/src/jcgp/backend/parser/TestCaseParser.java deleted file mode 100644 index d47d663..0000000 --- a/src/jcgp/backend/parser/TestCaseParser.java +++ /dev/null @@ -1,90 +0,0 @@ -package jcgp.backend.parser; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.util.Scanner; - -import jcgp.backend.modules.problem.TestCaseProblem; -import jcgp.backend.resources.ModifiableResources; - -public class TestCaseParser { - - private TestCaseProblem<?> problem; - - public TestCaseParser(TestCaseProblem<?> problem) { - this.problem = problem; - } - - public void parse(File file) { - FileReader fr; - try { - fr = new FileReader(file); - } catch (FileNotFoundException e) { - e.printStackTrace(); - return; - } - - Scanner in = new Scanner(fr); - boolean readingTestCases = false; - int inputs = 0, outputs = 0; - - problem.clearTestCases(); - - while (in.hasNextLine()) { - String nextLine = in.nextLine(); - - if (nextLine.startsWith(".i")) { - String[] split = nextLine.split(" +"); - inputs = Integer.parseInt(split[1]); - } else if (nextLine.startsWith(".o")) { - String[] split = nextLine.split(" +"); - outputs = Integer.parseInt(split[1]); - } else if (nextLine.startsWith(".p") || nextLine.startsWith(".t")) { - readingTestCases = true; - } else if (nextLine.startsWith(".e")) { - readingTestCases = false; - // set test cases? not safe probably - } else if (readingTestCases) { - String[] split = nextLine.split("( |\t)+"); - String[] inputCases = new String[inputs]; - String[] outputCases = new String[outputs]; - for (int i = 0; i < inputs; i++) { - inputCases[i] = split[i]; - } - for (int o = 0; o < outputs; o++) { - outputCases[o] = split[o + inputs]; - } - - problem.addTestCase(inputCases, outputCases); - } - } - - in.close(); - } - - public static void parseParameters(File file, ModifiableResources resources) { - - FileReader fr; - try { - fr = new FileReader(file); - } catch (FileNotFoundException e) { - e.printStackTrace(); - return; - } - - Scanner in = new Scanner(fr); - - while (in.hasNextLine()) { - String nextLine = in.nextLine(); - if (nextLine.startsWith(".i")) { - String[] split = nextLine.split(" +"); - resources.setInputs(Integer.parseInt(split[1])); - } else if (nextLine.startsWith(".o")) { - String[] split = nextLine.split(" +"); - resources.setOutputs(Integer.parseInt(split[1])); - } - } - in.close(); - } -} |