Ejemplo n.º 1
0
        private static void BasketMenu()
        {
            Console.WriteLine("\nMy basket:");

            if (basket.TShirts.Count == 0)
            {
                Console.WriteLine("\nThere is nothing in your basket at the moment.\n");
                return;
            }

            var userChoice = 0;
            var sb         = new StringBuilder();

            int total = basket.TotalPayable();

            PrintOut.PrintOutList(basket.TShirts);

            Console.WriteLine($"\nCurrent amount payable: {total}\n");

            sb
            .AppendLine("1. Remove item")
            .AppendLine("2. Proceed to checkout")
            .AppendLine("3. Continue shopping");

            Console.WriteLine(sb.ToString());
            Console.Write("Make a choice: ");

            try
            {
                userChoice = int.Parse(Console.ReadLine());
            }
            catch (FormatException)
            {
                Console.WriteLine("\nNon valid choice! Try again...\n");
                return;
            }

            switch (userChoice)
            {
            case 1:
                RemoveFromBasket();
                break;

            case 2:
                CheckOut();
                break;

            case 3:
                Console.WriteLine();
                break;

            default:
                Console.WriteLine("\nNon valid choice! Try again...\n");
                BasketMenu();
                break;
            }
        }
Ejemplo n.º 2
0
        private static void BrowseMenu()
        {
            var userChoice = 0;
            var browser    = new Browser()
            {
                TShirts = tshirts
            };
            var sb = new StringBuilder();

            sb
            .AppendLine()
            .AppendLine("Browse TShirts")
            .AppendLine("1. By Price Ascending")
            .AppendLine("2. By Price Descending")
            .AppendLine("3. By Color Ascending")
            .AppendLine("4. By Color Descending")
            .AppendLine("5. By Size Ascending")
            .AppendLine("6. By Size Descending")
            .AppendLine("7. By Fabric Ascending")
            .AppendLine("8. By Fabric Descending")
            .AppendLine("9. By Color/Size/Fabric Ascending")
            .AppendLine("10. By Color/Size/Fabric Descending")
            .AppendLine("11. Return to Main Menu");

            Console.WriteLine(sb.ToString());
            Console.Write("Make a choice: ");

            try
            {
                userChoice = int.Parse(Console.ReadLine());
            }
            catch (FormatException)
            {
                Console.WriteLine("\nNon valid choice! Try again...\n");
                return;
            }

            switch (userChoice)
            {
            case 1:
                browser.SortingMethod = SortingEnum.QuickPriceAsc;
                browser.SetSortingStrategy(new Sorter());
                tshirtsSorted = browser.Sort();
                PrintOut.PrintOutList(tshirtsSorted);
                break;

            case 2:
                browser.SortingMethod = SortingEnum.QuickPriceDesc;
                browser.SetSortingStrategy(new Sorter());
                tshirtsSorted = browser.Sort();
                PrintOut.PrintOutList(tshirtsSorted);
                break;

            case 3:
                browser.SortingMethod = SortingEnum.BubbleColorAsc;
                browser.SetSortingStrategy(new Sorter());
                tshirtsSorted = browser.Sort();
                PrintOut.PrintOutList(tshirtsSorted);
                break;

            case 4:
                browser.SortingMethod = SortingEnum.BubbleColorDesc;
                browser.SetSortingStrategy(new Sorter());
                tshirtsSorted = browser.Sort();
                PrintOut.PrintOutList(tshirtsSorted);
                break;

            case 5:
                browser.SortingMethod = SortingEnum.QuickSizeAsc;
                browser.SetSortingStrategy(new Sorter());
                tshirtsSorted = browser.Sort();
                PrintOut.PrintOutList(tshirtsSorted);
                break;

            case 6:
                browser.SortingMethod = SortingEnum.QuickSizeDesc;
                browser.SetSortingStrategy(new Sorter());
                tshirtsSorted = browser.Sort();
                PrintOut.PrintOutList(tshirtsSorted);
                break;

            case 7:
                browser.SortingMethod = SortingEnum.BucketFabricAsc;
                browser.SetSortingStrategy(new Sorter());
                tshirtsSorted = browser.Sort();
                PrintOut.PrintOutList(tshirtsSorted);
                break;

            case 8:
                browser.SortingMethod = SortingEnum.BucketFabricDesc;
                browser.SetSortingStrategy(new Sorter());
                tshirtsSorted = browser.Sort();
                PrintOut.PrintOutList(tshirtsSorted);
                break;

            case 9:
                browser.SortingMethod = SortingEnum.BubbleAllAsc;
                browser.SetSortingStrategy(new Sorter());
                tshirtsSorted = browser.Sort();
                PrintOut.PrintOutList(tshirtsSorted);
                break;

            case 10:
                browser.SortingMethod = SortingEnum.BubbleAllDesc;
                browser.SetSortingStrategy(new Sorter());
                tshirtsSorted = browser.Sort();
                PrintOut.PrintOutList(tshirtsSorted);
                break;

            case 11:
                Console.WriteLine();
                break;

            default:
                Console.WriteLine("\nNon valid choice! Try again...\n");
                BrowseMenu();
                break;
            }

            if (userChoice > 0 && userChoice < 11)
            {
                ChooseMenu();
            }
        }