コード例 #1
0
        /// <summary>
        /// Finds out which Droid the user wants deleted and deletes it
        /// </summary>
        /// <param name="droidCollection">DroidCollection</param>
        public void DeleteDroid(DroidCollection droidCollection)
        {
            //Gets the number of the droid to be deleted from the user
            int droidNumber = GetDroidNumber(droidCollection);

            //Output the message to confirm the droid to be deleted.
            Console.WriteLine();
            Console.ForegroundColor = ConsoleColor.DarkYellow;
            Console.WriteLine("Droid to delete:");
            Console.WriteLine("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
            //Calls the method to print out a single droid from the DroidCollection
            Console.WriteLine(droidCollection.GetASingleDroid(droidNumber));
            Console.WriteLine("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");

            //Gets the user input to confirm to delete the droid
            bool deleteDroid = BoolInput("Are you sure you want to delete the prevous droid?");

            if (deleteDroid)
            {//Delete the droid now that it has been confirmed and tell the user it has been deleted and reprint the list
                Console.ForegroundColor = ConsoleColor.DarkGreen;
                droidCollection.DeleteItem(droidNumber);
                Console.WriteLine("Droid Delted!");
            }
            Console.ForegroundColor = ConsoleColor.White;
        }