public void Construct(EMaterialMixType materialMixType)
        {
            switch (materialMixType)
            {
            case EMaterialMixType.EWood:
                _builder.SetPrice(EWOOD_PRICE);
                break;

            case EMaterialMixType.EIron:
                _builder.SetPrice(EIRON_PRICE);
                break;

            case EMaterialMixType.EGlass:
                _builder.SetPrice(EGLASS_PRICE);
                break;
            }
            _builder.SetMaterialMixType(materialMixType);
            _builder.SetColor("none");
            _builder.SetAccesoryType(EAccesoryType.EBasic);
        }
Ejemplo n.º 2
0
 public double GetPrice(EMaterialMixType materialType)
 {
     return(materialMix.Price);
 }
Ejemplo n.º 3
0
 public void SetMaterialMixType(EMaterialMixType type)
 {
     materialMix.Type = type;
 }
 public MaterialSeller(IMaterialBuilder builder, EMaterialMixType materialMixType)
 {
     _builder = builder;
     Construct(materialMixType);
 }
Ejemplo n.º 5
0
        private static void ClientMenu(FurnitureSeller furnitureSeller, VendingMachine1 vendingMachine)
        {
            int option = -1;

            while (option != 0)
            {
                Console.WriteLine("0. Exit");
                Console.WriteLine("1. Create");
                Console.WriteLine("2. Decorate");
                Console.WriteLine("3. Check a product");
                Console.WriteLine("4. Buy");
                Console.WriteLine("5. Insert Money");
                Console.WriteLine("6. Redraw Money");
                Console.WriteLine("7. Inspect stock");
                Console.WriteLine("8. See your money ammount");

                try
                {
                    option = Convert.ToInt32(Console.ReadLine());
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                }

                switch (option)
                {
                case 1:


                    EMaterialMixType materialMixType = GetMaterialType();
                    MaterialSeller   createSeller    = new MaterialSeller(new MaterialMixBuilder(), materialMixType);
                    MaterialMix      createdMaterial = createSeller.GetResult();
                    string           name;
                    EFurnitureType   furnitureType;
                    do
                    {
                        Console.WriteLine("Chair");
                        Console.WriteLine("Lift chair");
                        Console.WriteLine("Bar chair");
                        Console.WriteLine("Bench");
                        Console.WriteLine("Couch");
                        Console.WriteLine("Chesterfield");
                        Console.WriteLine("Bed");
                        Console.WriteLine("Day bed");
                        Console.WriteLine("Sofa bed");
                        Console.WriteLine("Biliard table");
                        Console.WriteLine("Television set");
                        Console.WriteLine("Coffe table");
                        Console.WriteLine("Dining table");
                        Console.WriteLine();
                        Console.WriteLine("Introduce the name of the product:");
                        name          = Console.ReadLine();
                        furnitureType = GetFurnitureType(name);
                    } while (furnitureType == EFurnitureType.ENone);


                    furnitureSeller.OrderFurniture(createdMaterial.Price, name, EFurnitureComplexity.Easy, new MaterialMix(), furnitureType);
                    break;

                case 2:
                    materialMixType = GetMaterialType();
                    createSeller    = new MaterialSeller(new MaterialMixBuilder(), materialMixType);
                    createdMaterial = createSeller.GetResult();
                    IMaterialAccesory materialAccesory = createdMaterial;

                    do
                    {
                        Console.WriteLine("Chair");
                        Console.WriteLine("Lift chair");
                        Console.WriteLine("Bar chair");
                        Console.WriteLine("Bench");
                        Console.WriteLine("Couch");
                        Console.WriteLine("Chesterfield");
                        Console.WriteLine("Bed");
                        Console.WriteLine("Day bed");
                        Console.WriteLine("Sofa bed");
                        Console.WriteLine("Biliard table");
                        Console.WriteLine("Television set");
                        Console.WriteLine("Coffe table");
                        Console.WriteLine("Dining table");
                        Console.WriteLine();
                        Console.WriteLine("Introduce the name of the product:");
                        name          = Console.ReadLine();
                        furnitureType = GetFurnitureType(name);
                    } while (furnitureType == EFurnitureType.ENone);

                    Console.WriteLine("1. Extendable");
                    Console.WriteLine("2. Handle");
                    Console.WriteLine("3. Height adjusted");
                    Console.WriteLine("4. Upholstered");

                    var op = 0;
                    do
                    {
                        try
                        {
                            Console.WriteLine("Choose a number.");
                            op = Convert.ToInt32(Console.ReadLine());
                            if (op < 1 || op > 4)
                            {
                                op = 0;
                            }
                        }
                        catch (Exception)
                        {
                            Console.WriteLine("Choose a number between 1 and 4!");
                        }
                    } while (op == 0);

                    switch (op)
                    {
                    case 1:
                        materialAccesory = new ExtendableDecorator(materialAccesory);
                        break;

                    case 2:
                        materialAccesory = new HandleDecorator(materialAccesory);
                        break;

                    case 3:
                        materialAccesory = new HeightAdjustedDecorator(materialAccesory);
                        break;

                    case 4:
                        materialAccesory = new UpholsteredDecorator(materialAccesory);
                        break;
                    }

                    //Console.WriteLine("What color do you want?");
                    //string color = Console.ReadLine();
                    materialAccesory.Assemble();



                    furnitureSeller.OrderFurniture(materialAccesory.Price, name, EFurnitureComplexity.Hard, new MaterialMix(), furnitureType);
                    break;

                case 3:
                    Seller       my_seller = new Seller(furnitureSeller);
                    RequestPrice request   = new RequestPrice(my_seller);
                    Console.WriteLine("Introduce the name of the product you want to check:");
                    string product = Console.ReadLine();
                    double price   = request.GetProductPrice(product);
                    if (price == -1)
                    {
                        Console.Write("Can't find this product.");
                    }
                    else
                    {
                        Console.WriteLine("We found your product.It's price is: " + price);
                    }
                    break;

                case 4:
                    Console.WriteLine("Choose your product Id");
                    int value = Convert.ToInt32(Console.ReadLine());
                    vendingMachine.UpdateState(EClientOption.BuyProduct, value, value, EMoneyType.Card);
                    break;

                case 5:
                    Console.WriteLine("How much do you want to add to your account?");
                    value = Convert.ToInt32(Console.ReadLine());
                    vendingMachine.UpdateState(EClientOption.InsertMoney, value, int.MaxValue, EMoneyType.Card);
                    break;

                case 6:
                    Console.WriteLine("How much do you want to redraw?");
                    value = Convert.ToInt32(Console.ReadLine());
                    vendingMachine.UpdateState(EClientOption.RetractMoney, value, int.MaxValue, EMoneyType.Card);
                    break;

                case 7:
                    vendingMachine.UpdateState(EClientOption.InspectStock, double.NaN, int.MaxValue, EMoneyType.Card);
                    break;

                case 8:
                    vendingMachine.UpdateState(EClientOption.SeeMoneyAmmount, int.MaxValue, int.MaxValue, EMoneyType.Card);
                    break;

                default:
                    break;
                }
            }
        }