public override WordData PerformInsert(InsertionSpace space, string word) { var wordData = new WordData(word); for (int i = 0, q = space.GetStartPosition(true); i < word.Length; i++, q++) { _grid.GridData[q][StartRowCol].SubmitText(word[i].ToString()); wordData.AssignNewLetter(StartRowCol, q); } return(wordData); }
private SubmissionResponse SubmitTextInternal(DirectionalProcess dirProcess, int sizeValue, string text) { var finalResult = false; WordData wordData = null; var originalCol = dirProcess.StartRowCol; var iterateCol = originalCol; var exitLoop = false; InsertionSpace space = null; do { space = GetSuitableSpaces(dirProcess, iterateCol, text); var canInsert = space != null && text.Length <= space.EmptySpaces; // When it can't insert try the next row, moving back to the beginning when it hits the end of the rows. if (!canInsert) { iterateCol = iterateCol + 1 > sizeValue - 1 ? 0 : iterateCol + 1; } finalResult = canInsert; // Exit loop if it can insert, or if we've tried every row and gone back to the original row. exitLoop = canInsert || originalCol == iterateCol; } while (!exitLoop); // If validation passes, then insert it. if (finalResult) { wordData = PerformInsert(dirProcess, text, space); } return(new SubmissionResponse(finalResult, wordData)); }
public virtual WordData PerformInsert(InsertionSpace space, string word) { throw new NotImplementedException(); }
private WordData PerformInsert(DirectionalProcess dirProcess, string value, InsertionSpace space) { return(dirProcess.PerformInsert(space, value)); }