Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Linq;
- using System.Text;
- using System.Collections;
- using System.Threading.Tasks;
- namespace ConsoleApp1
- {
- class Program
- {
- public static List<string> InputChord(string chord)
- {
- // define notes
- Dictionary<string, int> rootKey = new Dictionary<string, int>
- {
- {"A", 0},
- {"A#", 1},
- {"B", 2},
- {"C", 3},
- {"C#", 4},
- {"D", 5},
- {"D#", 6},
- {"E", 7},
- {"F", 8},
- {"F#", 9},
- {"G", 10},
- {"G#", 11}
- };
- var rootKeyList = rootKey.Keys.ToList();
- // input check
- Console.WriteLine("Please put the chord notes divided with '-' : ");
- bool check = true;
- while (check)
- {
- var input = Console.ReadLine().ToUpper();
- var chordTones = input.Split('-').ToList();
- foreach (var note in chordTones)
- {
- if (String.IsNullOrWhiteSpace(input))
- {
- Console.WriteLine("Please provide chord tones (at least three notes): ");
- break;
- }
- else if (input.Count() < 3)
- {
- Console.WriteLine("Please provide at least 3 notes: ");
- break;
- }
- else if (!rootKeyList.Contains(note))
- {
- Console.WriteLine("Incorrect {0} note, please correct: ", note);
- break;
- };
- }
- return chordTones;
- }
- }
- static void Main(string[] args)
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement