private void CreateLineGrid() { int xDimension = LetterHeight; int yDimension = LetterWidth * NumLettersInLine + SpaceWidth * NumSpacesInLine; Grid = new char[xDimension, yDimension]; char[] wordCharArray = Word.ToCharArray(); int lastIndex = 0; for (int i = 0; i < wordCharArray.Length; i++) { char letter = wordCharArray[i]; LetterGrid letterGrid = new LetterGrid(letter); lastIndex = AddLetterGrid(lastIndex, letterGrid); } }
private int AddLetterGrid(int lastIndex, LetterGrid letterGrid) { int lastYIndex = 0; if (lastIndex > 0) { lastIndex++; } for (int i = 0; i < letterGrid.Grid.GetLength(0); i++) { for (int j = 0; j < letterGrid.Grid.GetLength(1); j++) { lastYIndex = lastIndex + j; Grid[i, lastYIndex] = letterGrid.Grid[i, j]; } } return(lastYIndex); }
public static void Main(string[] args) { var A = new LetterGrid('A'); A.PrintGrid(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); var word = new WordGrid("A A"); word.PrintGrid(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); word = new WordGrid("AAAAA"); word.PrintGrid(); Console.ReadLine(); }