public void takeInput() { tokenizer = new StringTokenizer(massInputBox.Text); tokenizer.IgnoreWhiteSpace = true; tokenizer.SymbolChars = new char[] { '-' }; Token token; holeRadius = float.Parse(radiusBox.Text, CultureInfo.InvariantCulture); Color[] holeColors = new Color[8] { Color.Cyan, Color.Crimson, Color.DarkOrange, Color.Blue, Color.Fuchsia, Color.BlueViolet, Color.Lime, Color.Black }; int counter = 0; do { token = tokenizer.Next(); parseCoordinates(ref token, ref counter); if (counter % 3 == 2) { float holeXEscape = float.Parse(xEscapeBox.Text, CultureInfo.InvariantCulture); float holeYEscape = float.Parse(yEscapeBox.Text, CultureInfo.InvariantCulture); HoleInfo holeInfo = new HoleInfo(holeXCoordinate, holeYCoordinate, holeRadius, holeXEscape, holeYEscape, holeColors[colorCounter % 8]); holeInfoList.Add(holeInfo); counter++; } }while (token.Kind != TokenKind.EOF); colorCounter++; }
public bool failsHoleConditions(HoleInfo holeOne, HoleInfo holeTwo) { setHoleVariables(holeOne, holeTwo); if (distanceBetweenHoles <= 0) { return(true); } else if (distanceBetweenHoles <= minimumSpace) { holeMinSpaceFailed = true; return(true); } return(false); }
private void setHoleVariables(HoleInfo holeOne, HoleInfo holeTwo) { float holeOneRadius = holeOne.holeDiameter / 2; float centeredHoleOneXCoordinate = holeOne.holeXCoordinate + holeOne.holeXEscape; float centeredHoleOneYCoordinate = holeOne.holeYCoordinate - holeOne.holeYEscape; float holeTwoRadius = holeTwo.holeDiameter / 2; float centeredHoleTwoXCoordinate = holeTwo.holeXCoordinate + holeTwo.holeXEscape; float centeredHoleTwoYCoordinate = holeTwo.holeYCoordinate - holeTwo.holeYEscape; float holeXDifference = centeredHoleOneXCoordinate - centeredHoleTwoXCoordinate; float holeYDifference = centeredHoleOneYCoordinate - centeredHoleTwoYCoordinate; float holeXDifferenceSquared = holeXDifference * holeXDifference; float holeYDifferenceSquared = holeYDifference * holeYDifference; float distanceBetweenCenters = (float)Math.Sqrt(holeXDifferenceSquared + holeYDifferenceSquared); distanceBetweenHoles = distanceBetweenCenters - (holeOneRadius + holeTwoRadius); }
public InvalidHole(HoleInfo holeInfo, List <String> errorType) { this.holeInfo = holeInfo; this.errorType = errorType; }