private static BreedingTest ParseBreedingTest(string[][] data) { if (data.Length < 2) { throw new InputException("Breeding test must list at least two tests"); } BreedingTest test = new BreedingTest(); for (int k = 0; k < data.Length; k++) { int offset = k == 0 ? 1 : 0; string[] item = data[k]; if (item.Length < 2 + offset) { throw new InputException("Testing pair must start with both parents"); } TestPair pair = new TestPair(GetFlower(item[offset]), GetFlower(item[offset + 1])); if (item.Length < 3 + offset) { throw new InputException("Testing pair must list one or more results"); } if ((item.Length - offset) % 2 == 1) { throw new InputException("Each testing result must specify a chance in percentage"); } for (int j = offset + 2; j < item.Length; j += 2) { pair.AddTestResult(GetFlowerColor(item[j]), int.Parse(item[j + 1])); } test.AddTestPair(pair); } return(test); }
public void AddTestPair(TestPair pair) { testPairs.Add(pair); }