public void ProgressionTest_swapChords() { _progression = new Progression(); _progression.addChord(ChordFactory.getChordByName("C")); _progression.addChord(ChordFactory.getChordByName("Am7")); _progression.addChord(ChordFactory.getChordByName("G#(add9)")); _progression.swapChords(0, 1); Assert.AreEqual("Am7, C, G#(add9)", _progression.getChordNames()); }
public static Progression swapChords(Progression progression) { string inputError = "\nI'm sorry that was not a valid coice." + "\nPlease try again."; string choice; bool validChordPositionChoiceOne = false; bool validChordPositionChoiceTwo = false; if (progression.getSize() == 0) { System.Console.WriteLine("\nThere are no chords in your progression."); } else { while (validChordPositionChoiceOne == false) { int i; int j; System.Console.WriteLine("\nWhat chord would you like to swap?"); for (i = 1; i <= progression.getSize(); i++) { System.Console.WriteLine(i + ") " + progression.getChord(i - 1).getName()); } choice = System.Console.ReadLine(); for (i = 1; i <= progression.getSize(); i++) { if (choice == i.ToString()) { validChordPositionChoiceOne = true; while (validChordPositionChoiceTwo == false) { System.Console.WriteLine("\nWhat chord would you like to swap " + progression.getChord(i - 1).getName() + " with?"); choice = System.Console.ReadLine(); for (j = 1; j <= progression.getSize(); j++) { if (choice == j.ToString()) { validChordPositionChoiceTwo = true; progression.swapChords(i - 1, j - 1); System.Console.WriteLine(progression.getChord(i - 1).getName() + " has been swapped with " + progression.getChord(j - 1).getName()); } } if (validChordPositionChoiceTwo == false) { System.Console.WriteLine(inputError); } } } } if (validChordPositionChoiceOne == false) { System.Console.WriteLine(inputError); } } } return(progression); }