//gets album information for single album and displays it public void DisplayLP(LP x) { Console.WriteLine("Artist: {0} Album: {1} Release Year: {2} ID: {3}", x.GetArtist(), x.GetTitle(), x.GetReleaseYear(), x.GetID()); }
//removes LP by ID // locates LP in Repo // asks user to confirm removal // deletes album from AllLPs list //Note: if ID does not exist or repo empty (but not null), program will display that it //if removing an object but the information is empty //specs did not mention to handle this case specifically, but will fix if necessary for the assignment public void RemoveLP() { int x = Viewer.SearchLP(); // will return the interger of the LP ID LP LPToBeFound = Repo.ReadById(x); if (LPToBeFound == null) { Console.WriteLine("There was no album in the collection with ID {0}", x); } else { Console.WriteLine("you have selected to remove:\nID: {0}, Title: {1}, Artist: {2}, " + "Release Year: {3}", LPToBeFound.GetID(), LPToBeFound.GetTitle(), LPToBeFound.GetArtist(), LPToBeFound.GetReleaseYear()); Console.WriteLine("press any key to continue with removal: "); Console.ReadKey(); Console.WriteLine(); //Repo.Delete(LPToBeFound.GetID()); if (Viewer.ConfirmRemoveLP(LPToBeFound)) { Repo.Delete(LPToBeFound.GetID()); Console.WriteLine("{0} has been deleted", LPToBeFound.GetTitle()); } else { Console.WriteLine("Removal has been cancelled"); } } }
// confirms that user would like to remove the album, returns true if yes, //false otherwise public bool ConfirmRemoveLP(LP x) { bool remove; while (true) { Console.WriteLine("Are you sure you want to remove this album?:\nID: {0}, Title: {1}, Artist: {2}, " + "Release Year: {3}", x.GetID(), x.GetTitle(), x.GetArtist(), x.GetReleaseYear()); Console.WriteLine(); Console.Write("enter \"Y\" to REMOVE or \"N\" to CANCEL: "); string YorN = Console.ReadLine().ToLower(); Console.WriteLine(); if (YorN == "y") { remove = true; break; } else if (YorN == "n") { remove = false; break; } else { Console.WriteLine("Invalid entry, please Try again"); continue; } } Console.WriteLine(); return(remove); }
//asks for id from user, validates that it is a number //finds the LP in the Repo list //prints requested information public void SearchLPs() { int x = Viewer.SearchLP(); // will return the interger of the LP ID LP LPToBeFound = Repo.ReadById(x); if (LPToBeFound == null) { Console.WriteLine("There was no album in the collection with ID {0}", x); } else { Console.WriteLine("Here is the information you requested:\nID: {0}, Title: {1}, Artist: {2}, " + "Release Year: {3}", LPToBeFound.GetID(), LPToBeFound.GetTitle(), LPToBeFound.GetArtist(), LPToBeFound.GetReleaseYear()); } }