private static bool EvaluateModeAnswer(DiatonicMode mode, Guitar guitar, int stringNumber, int position, int[][] fretNumbers, string answer) { var pitch = guitar.GetPitch(stringNumber, position + fretNumbers[0][0]); var combinations = from keyNote in new[] { pitch.Note, pitch.Note.Invert() }.Distinct() from modeName in new[] { mode.GetName(), mode.GetAlternativeName() }.Distinct() select $"{keyNote.ToString().ToLowerInvariant()} {modeName.ToLowerInvariant()}"; return(combinations.Contains(answer)); }
private static void PrintExcercise(Guitar guitar, int stringNumber, int[][] fretNumbers, int maxFretNumber, int questionStringIndex, int questionFretIndex, int position) { var questionStringNumber = stringNumber + questionStringIndex; var sb = new StringBuilder(); var stringFrets = new bool[maxFretNumber + 1]; for (var i = guitar.NumberOfStrings - 1; i >= 0; i--) { sb.Clear(); Array.Clear(stringFrets, 0, stringFrets.Length); int fretNumberIndex = i - stringNumber; int[] stringFretNumbers; if (0 <= fretNumberIndex && fretNumberIndex < fretNumbers.Length) { stringFretNumbers = fretNumbers[fretNumberIndex]; for (var j = 0; j < stringFretNumbers.Length; j++) { stringFrets[stringFretNumbers[j]] = true; } } else { stringFretNumbers = null; } sb.Append(guitar.GetPitch(i, 0).Note.ToString().PadRight(3)).Append('-').Append('|'); for (var j = 0; j < stringFrets.Length; j++) { sb.Append('-'); if (!stringFrets[j]) { sb.Append('-'); } else if (i == questionStringNumber && j == stringFretNumbers[questionFretIndex]) { sb.Append('?'); } else { sb.Append('O'); } sb.Append('-').Append('|'); } sb.Append('-'); Console.WriteLine(sb.ToString()); } Console.WriteLine(new string(' ', 5) + position.ToString().PadLeft(2)); }