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 ChooseMenu()
        {
            var userChoice = 0;

            Console.Write("Choose a TShirt or [0] to return to Main Menu: ");

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

            if (userChoice == 0)
            {
                Console.WriteLine();
                return;
            }
            else if (userChoice < 0 || userChoice > tshirts.Count)
            {
                Console.WriteLine("\nNon valid choice! Try again...\n");
                return;
            }
            else
            {
                tshirt = tshirtsSorted[userChoice - 1];
                Console.WriteLine("\nYour Choice:");
            }

            PrintOut.PrintOutSingle(tshirt);

            AddToBasket(userChoice);
        }
Ejemplo n.º 3
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();
            }
        }
Ejemplo n.º 4
0
        private static void CreateMenu()
        {
            var userChoice = 0;
            var colors     = Enum.GetNames(typeof(ColorEnum)).ToList();
            var sizes      = Enum.GetNames(typeof(SizeEnum)).ToList();
            var fabrics    = Enum.GetNames(typeof(FabricEnum)).ToList();

            var newTshirt = new TShirt();

            Console.WriteLine("\nColors");

            for (int i = 0; i < colors.Count; i++)
            {
                //Console.Write($"{(int)(ColorEnum)i + 1}. ");
                Console.Write($"{i + 1}. ");
                Console.WriteLine(colors[i]);
            }

            Console.Write("Choose color: ");

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

            if (userChoice <= 0 || userChoice > colors.Count)
            {
                Console.WriteLine("\nNo such choice! Try again...\n");
                return;
            }

            newTshirt.Color = (ColorEnum)(userChoice - 1);

            Console.WriteLine("\nSizes");

            for (int i = 0; i < sizes.Count; i++)
            {
                Console.Write($"{i + 1}. ");
                Console.WriteLine(sizes[i]);
            }

            Console.Write("Choose Size: ");

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

            if (userChoice <= 0 || userChoice > sizes.Count)
            {
                Console.WriteLine("\nNo such choice! Try again...\n");
                return;
            }

            newTshirt.Size = (SizeEnum)(userChoice - 1);

            Console.WriteLine("\nFabrics");

            for (int i = 0; i < sizes.Count; i++)
            {
                Console.Write($"{i + 1}. ");
                Console.WriteLine(fabrics[i]);
            }

            Console.Write("Choose Fabric: ");

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

            if (userChoice <= 0 || userChoice > fabrics.Count)
            {
                Console.WriteLine("\nNo such choice! Try again...\n");
                return;
            }

            newTshirt.Fabric = (FabricEnum)(userChoice - 1);

            newTshirt.SetPricingStrategy(new PriceTag(tshirt));
            newTshirt.GetPriceTag();

            Console.WriteLine("\nYour Choice:");
            PrintOut.PrintOutSingle(newTshirt);

            tshirt = newTshirt;

            AddToBasket(null);
        }