Exemplo n.º 1
0
 public MaterialMixDecorator(IMaterialAccesory materialAccesory)
 {
     DecoratedMaterial              = new MaterialMix();
     DecoratedMaterial.Type         = materialAccesory.Type;
     DecoratedMaterial.AccesoryType = materialAccesory.AccesoryType;
     DecoratedMaterial.Color        = "black";
     DecoratedMaterial.Price        = materialAccesory.Price;
 }
Exemplo n.º 2
0
 public Furniture1(int id, double price, string name, EFurnitureComplexity furnitureComplexity, IMaterialAccesory materialAccesory)
 {
     Id    = id;
     Name  = name;
     Price = price;
     FurnitureComplexity = furnitureComplexity;
     MaterialAccesory    = materialAccesory;
 }
Exemplo n.º 3
0
 public SofaBed(int id, double price, string name, EFurnitureComplexity furnitureComplexity, IMaterialAccesory materialMixBuilder, EFurnitureType furnitureType) :
     base(id, price, name, furnitureComplexity, materialMixBuilder)
 {
     FurnitureType = furnitureType;
 }
 public override Furniture1 GetFurniture(double price, string name, EFurnitureComplexity furnitureComplexity, IMaterialAccesory materialMixBuilder, EFurnitureType furnitureType)
 => new LiftChair(LastId++, price, name, furnitureComplexity, materialMixBuilder, EFurnitureType.EBarChair);
Exemplo n.º 5
0
 public HeightAdjustedDecorator(IMaterialAccesory myMaterial) : base(myMaterial)
 {
     DecoratedMaterial.AccesoryType = Builder.EAccesoryType.EHeightAdjusted;
     SetPrice();
 }
 public HandleDecorator(IMaterialAccesory myMaterial) : base(myMaterial)
 {
     DecoratedMaterial.AccesoryType = Builder.EAccesoryType.EHandle;
     SetPrice();
 }
Exemplo n.º 7
0
 public abstract Furniture1 GetFurniture(double price, string Name, EFurnitureComplexity furnitureComplexity, IMaterialAccesory materialMixBuilder, EFurnitureType furnitureType);
Exemplo n.º 8
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;
                }
            }
        }
Exemplo n.º 9
0
 public UpholsteredDecorator(IMaterialAccesory myMaterial) : base(myMaterial)
 {
     DecoratedMaterial.AccesoryType = Builder.EAccesoryType.EUpholstered;
     SetPrice();
 }
Exemplo n.º 10
0
        public int OrderFurniture(double price, string name, EFurnitureComplexity furnitureComplexity, IMaterialAccesory materialMixBuilder, EFurnitureType furnitureType)
        {
            Furniture1       furniture;
            FurnitureFactory furnitureFactory;

            switch (furnitureType)
            {
            case EFurnitureType.EBarChair:
            {
                furnitureFactory = new BarChairFactory();
                break;
            }

            case EFurnitureType.EBed:
            {
                furnitureFactory = new BedFactory();
                break;
            }

            case EFurnitureType.EBench:
            {
                furnitureFactory = new BenchFactory();
                break;
            }

            case EFurnitureType.EBiliardTable:
            {
                furnitureFactory = new BiliardTableFactory();
                break;
            }

            case EFurnitureType.EChair:
            {
                furnitureFactory = new ChairFactory();
                break;
            }

            case EFurnitureType.EChesterField:
            {
                furnitureFactory = new ChesterFieldFactory();
                break;
            }

            case EFurnitureType.ECoffeTable:
            {
                furnitureFactory = new CoffeTableFactory();
                break;
            }

            case EFurnitureType.ECouch:
            {
                furnitureFactory = new Couchfactory();
                break;
            }

            case EFurnitureType.EDayBed:
            {
                furnitureFactory = new DayBedFactory();
                break;
            }

            case EFurnitureType.EDiningTable:
            {
                furnitureFactory = new DiningTableFactory();
                break;
            }

            case EFurnitureType.ELiftChair:
            {
                furnitureFactory = new LiftChairFactory();
                break;
            }

            case EFurnitureType.ESofaBed:
            {
                furnitureFactory = new SofaBedFactory();
                break;
            }

            case EFurnitureType.ETelevisionSet:
            {
                furnitureFactory = new TelevisionSetFactory();
                break;
            }

            default:
            {
                Console.WriteLine("Unknown furniture type!");
                return(0);
            }
            }
            furniture = furnitureFactory.GetFurniture(price, name, furnitureComplexity, materialMixBuilder, furnitureType);
            OrderedFurniture.Add(furniture.Id, furniture);
            return(furniture.Id);
        }