Пример #1
0
        private LibraryItem SelectItem()
        {
            Typer.TypeLine("What item would you like to select (use item's index)?");
            Console.Write("> ");

            if (Int32.TryParse(Console.ReadLine(), out int itemIndex) && itemIndex >= 1 && itemIndex <= LibraryItems.Count)
            {
                --itemIndex;
                return(LibraryItems[itemIndex]);
            }

            Typer.TypeLine("Invalid index, returning to main menu.");
            return(null);
        }
Пример #2
0
        public void ReturnItem()
        {
            LibraryItem item = SelectItem();

            if (item == null)
            {
                return;
            }

            if (!item.Available)
            {
                item.Available = true;
                Typer.TypeLine($"You have returned \"{item.Title}\".");
            }
            else
            {
                Typer.TypeLine($"You can't return an item you didn't check out. Returning to main menu.");
            }
        }
Пример #3
0
        public void CheckoutItem()
        {
            LibraryItem item = SelectItem();

            if (item == null)
            {
                return;
            }

            if (item.Available)
            {
                item.Available = false;
                Typer.TypeLine($"You have checked out \"{item.Title}\".");
            }
            else
            {
                Typer.TypeLine($"This item is already checked out, sorry. Returning to main menu.");
            }
        }