public void DoPayment(TShirt tshirt)
        {
            decimal basePrice = 0.0m;

            switch (tshirt.Fabric)
            {
            case Fabric.WOOL:
            //break;
            case Fabric.COTTON:
                basePrice = 20.0m;
                break;

            case Fabric.POLYESTER:
            //break;
            case Fabric.RAYOL:
                basePrice = 15.0m;
                break;

            case Fabric.LINEN:
            //break;
            case Fabric.CASHMERE:
            //break;
            case Fabric.SILK:
                basePrice = 30.0m;
                break;
            }

            switch (tshirt.Size)
            {
            //case Size.XS:
            //    break;
            //case Size.S:
            //    break;
            //case Size.M:
            //    break;

            //this price changes only for these size
            case Size.L:
            //break;
            case Size.XL:
            //break;
            case Size.XXL:
            //break;
            case Size.XXXL:
                basePrice += basePrice * 0.05m;
                break;
            }

            //The price is the same for all colors
            Console.WriteLine($"The price of your T-Shirt is: {basePrice: 0.##}\u20AC");
        }
        public void DoPayment(TShirt tshirt)
        {
            decimal basePrice = 0.0m;

            switch (tshirt.Fabric)
            {
            case Fabric.WOOL:
            case Fabric.COTTON:
                basePrice = 25.0m;
                break;

            case Fabric.POLYESTER:
            case Fabric.RAYOL:
                basePrice = 20.0m;
                break;

            case Fabric.LINEN:
            case Fabric.CASHMERE:
            case Fabric.SILK:
                basePrice = 35.0m;
                break;
            }

            switch (tshirt.Size)
            {
            //this price changes only for these size
            case Size.L:
            case Size.XL:
            case Size.XXL:
            case Size.XXXL:
                basePrice += basePrice * 0.07m;
                break;
            }

            switch (tshirt.Color)
            {
            //the price changes only for these colors
            case Color.INDIGO:
            case Color.VIOLET:
                basePrice += basePrice * 0.03m;
                break;
            }

            //The price is the same for all colors
            Console.WriteLine($"The price of your T-Shirt is: {basePrice: 0.##}\u20AC");// Euro sign
        }
Example #3
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.UTF8;
            int  fabric, size, color, paymnetMethod;
            Menu menu = new Menu();

            while (true)
            {
                menu.FabricMenu();
                while (!(int.TryParse(Console.ReadLine(), out fabric) && (fabric >= 1 && fabric <= 7)))
                {
                    Console.WriteLine("Wrong choise!");
                    Console.WriteLine();
                    menu.FabricMenu();
                }

                Console.WriteLine();

                menu.ColorMenu();
                while (!(int.TryParse(Console.ReadLine(), out color) && (color >= 1 && color <= 7)))
                {
                    Console.WriteLine("Wrong choise!");
                    Console.WriteLine();
                    menu.ColorMenu();
                }

                Console.WriteLine();

                menu.SizeMenu();
                while (!(int.TryParse(Console.ReadLine(), out size) && (size >= 1 && size <= 7)))
                {
                    Console.WriteLine("Wrong choise!");
                    Console.WriteLine();
                    menu.SizeMenu();
                }

                Console.WriteLine();

                TShirt tshirt = new TShirt((Color)(color - 1), (Size)(size - 1), (Fabric)(fabric - 1));

                menu.PaymentMethodeMenu();
                while (!(int.TryParse(Console.ReadLine(), out paymnetMethod) && (paymnetMethod >= 1 && paymnetMethod <= 3)))
                {
                    Console.WriteLine("Wrong choise!");
                    Console.WriteLine();
                    menu.PaymentMethodeMenu();
                }

                Console.WriteLine();

                IPaymentStrategy paymentStrategy = null;

                switch (paymnetMethod)
                {
                case 1:
                    paymentStrategy = new CretitCardPaymentStrategy();
                    break;

                case 2:
                    paymentStrategy = new BankTransferPaymentStrategy();
                    break;

                case 3:
                    paymentStrategy = new CashPaymentStrategy();
                    break;
                }

                tshirt.SetPaymentsStrategy(paymentStrategy);
                tshirt.Pay();
                Console.WriteLine();
                Console.WriteLine("Do you want to buy another T-Shirt? (yes/no)");
                string answer = Console.ReadLine();
                if (!answer.Equals("yes"))
                {
                    break;
                }

                Console.WriteLine();
            }
        }