Esempio n. 1
0
        private static List <IFurniture> GenerateRandomFurnitureList(int count)
        {
            List <IFurniture> list = new List <IFurniture>();

            Random random = new Random();

            for (int i = 0; i < count; i++)
            {
                IFurniture f = CreateRandomFurniture(random);
                f.Name   = f.GetType() + " #" + i;
                f.Size   = random.Next(1, 1000) / 10;
                f.Weight = random.Next(1, 1000) / 10;

                for (int j = 0; j < random.Next(1, 10); j++)
                {
                    IMaterial material = CreateRandomMaterial(random);
                    f.Materials.Add(new Materials.MaterialSpecification()
                    {
                        Material = material, Count = random.Next(1000, 3000) / 100
                    });
                }

                list.Add(f);
            }
            return(list);
        }
Esempio n. 2
0
        public void Remove(IFurniture furniture)
        {
            var elementToRemove = this.furnitures.FirstOrDefault(f =>
            {
                var result = 0;

                result = f.GetType() == furniture.GetType() ? result + 1 : result;
                result = f.Material == furniture.Material ? result + 1 : result;
                result = f.Model == furniture.Model ? result + 1 : result;
                result = f.Price == furniture.Price ? result + 1 : result;

                return(result == 4);
            }
                                                                 );

            if (elementToRemove != null)
            {
                this.furnitures.Remove(elementToRemove);
            }
        }
 public void AddFurniture(IFurniture furniture)
 {
     Guard.WhenArgument(furniture, furniture.GetType().Name).IsNull().Throw();
     this.furniture.Add(furniture.Model, furniture);
 }