public void ProgressionTest_replaceChord() { _progression = new Progression(); _progression.addChord(ChordFactory.getChordByName("C")); _progression.addChord(ChordFactory.getChordByName("Am7")); _progression.addChord(ChordFactory.getChordByName("G#(add9)")); _progression.replaceChord(0, ChordFactory.getChordByName("Db9")); Assert.AreEqual("Db9, Am7, G#(add9)", _progression.getChordNames()); }
public static Progression replaceChord(Progression progression) { string inputError = "\nI'm sorry that was not a valid coice." + "\nPlease try again."; string choice; bool validChordPositionChoice; bool validChordNameChoice; string newChordName; if (progression.getSize() == 0) { System.Console.WriteLine("\nThere are no chords in your progression."); } else { validChordPositionChoice = false; while (validChordPositionChoice == false) { int i; System.Console.WriteLine("\nWhat chord would you to replace?"); 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()) { string oldChordName = progression.getChord(i - 1).getName(); validChordPositionChoice = true; validChordNameChoice = false; while (validChordNameChoice == false) { System.Console.WriteLine("\nWhat chord would you like to replace " + progression.getChord(i - 1).getName() + " with?"); newChordName = System.Console.ReadLine(); if (ChordController.checkChordName(newChordName)) { validChordNameChoice = true; progression.replaceChord(i - 1, ChordFactory.getChordByName(newChordName)); System.Console.WriteLine("\n" + oldChordName + " has been replaced with " + newChordName); } else { System.Console.WriteLine(inputError); } } } } if (validChordPositionChoice == false) { System.Console.WriteLine(inputError); } } } return(progression); }