public Allocation ExtractAllocation(string line, int numOfProcessors, int numOfTasks, Validations validations) { if (InsideAllocationData) { ExtractID(line, validations); ExtractMapData(line, validations); if (AllocationMapData != null && AllocationID >= 0) { Map newMapData = new Map(AllocationMapData); Allocation newAllocation = new Allocation(AllocationID, newMapData); // Convert the map data to a 2D array newAllocation.MapMatrix = newMapData.ConvertToMatrix( numOfProcessors, numOfTasks, validations); // Check the number of tasks in each allocation int sumOfTasks = newAllocation.CountTasks(); bool validMapData = validations.CheckValidQuantity( sumOfTasks.ToString(), numOfTasks.ToString(), "tasks in a allocation", ErrorCode.INVALID_MAP); if (validMapData) { Allocations.Add(newAllocation); return(newAllocation); } } } return(null); }