예제 #1
0
        private void ListItems() //will need a 'List<Item> libraryList' parameter
        {
            int i = 1;

            Console.Clear();
            foreach (Item item in libraryList)
            {
                //go back and format this or, inside of the Item (or children) class, setup a DisplayItem(); method

                if (item is Book && !item.CheckedIn)
                {
                    Book b = (Book)item;
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.WriteLine($"{i} - TITLE: {item.Title}");

                    Console.ForegroundColor = ConsoleColor.White;
                    Console.WriteLine($"    AUTHOR: {item.Author}\n    NUMBER OF PAGES: {b.NumberOfPages}\n    DESCRIPTION: {item.Description}");
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine($"     DUE DATE: {item.DueDate}");
                    Console.ResetColor();
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.WriteLine("=============================================================================================================");
                }

                else if (item is Book && item.CheckedIn)
                {
                    Book b = (Book)item;
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.WriteLine($"{i} - TITLE: {item.Title}");

                    Console.ForegroundColor = ConsoleColor.White;
                    Console.WriteLine($"    AUTHOR: {item.Author}\n    NUMBER OF PAGES: {b.NumberOfPages}");
                    Console.WriteLine($"    Description: {item.Description}");
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine($"    Available for CheckOut");
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.WriteLine("=============================================================================================================");
                }

                if (item is Magazine && !item.CheckedIn)
                {
                    Magazine b = (Magazine)item;
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.WriteLine($"{i} - TITLE: {item.Title}");

                    Console.ForegroundColor = ConsoleColor.White;
                    Console.WriteLine($"    AUTHOR: {item.Author}\n    NUMBER OF PAGES: {b.NumberOfPages}\n    DESCRIPTION: {item.Description}");
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine($"      DUE DATE: {item.DueDate}");
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.WriteLine("=============================================================================================================");
                }

                else if (item is Magazine && item.CheckedIn)
                {
                    Magazine b = (Magazine)item;
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.WriteLine($"{i} - TITLE: {item.Title}");
                    Console.ForegroundColor = ConsoleColor.White;

                    Console.WriteLine($"    AUTHOR: {item.Author}\n    NUMBER OF PAGES: {b.NumberOfPages}");
                    Console.WriteLine($"    Description: {item.Description}");
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine($"    Available for CheckOut");
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.WriteLine("=============================================================================================================");
                }


                if (item is CD && !item.CheckedIn)
                {
                    CD b = (CD)item;
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.WriteLine($"{i} - TITLE: {item.Title}");

                    Console.ForegroundColor = ConsoleColor.White;

                    Console.WriteLine($"    AUTHOR: {item.Author}\n    CD Length: {b.Length}\n    DESCRIPTION: {item.Description}");
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine($"      DUE DATE: {item.DueDate}");
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.WriteLine("=============================================================================================================");
                }

                else if (item is CD && item.CheckedIn)
                {
                    CD b = (CD)item;
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.WriteLine($"{i} - TITLE: {item.Title}");

                    Console.ForegroundColor = ConsoleColor.White;

                    Console.WriteLine($"    AUTHOR: {item.Author}\n    CD Length: {b.Length}");
                    Console.WriteLine($"    Description: {item.Description}");
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine($"    Available for CheckOut");
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.WriteLine("=============================================================================================================");
                }

                if (item is Movie && !item.CheckedIn)
                {
                    Movie b = (Movie)item;
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.WriteLine($"{i} - TITLE: {item.Title}");

                    Console.ForegroundColor = ConsoleColor.White;

                    Console.WriteLine($"    AUTHOR: {item.Author}\n    Movie Length: {b.Duration}\n    DESCRIPTION: {item.Description}");
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine($"      DUE DATE: {item.DueDate}");
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.WriteLine("=============================================================================================================");
                }

                else if (item is Movie && item.CheckedIn)
                {
                    Movie b = (Movie)item;
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.WriteLine($"{i} - TITLE: {item.Title}");

                    Console.ForegroundColor = ConsoleColor.White;

                    Console.WriteLine($"    AUTHOR: {item.Author}\n    Movie Length: {b.Duration}");
                    Console.WriteLine($"    Description: {item.Description}");
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine($"    Available for CheckOut");
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.WriteLine("=============================================================================================================");
                }
                i++;
            }
            UserContinue();
        }