Beispiel #1
0
        string ShowResult(Kit setOfFurniture)
        {
            ChairServices chairServices = new ChairServices();

            return($"\n{setOfFurniture.Name} Kit includes:\n{setOfFurniture.Table.Size} {setOfFurniture.Table.Material} " +
                   $"{setOfFurniture.Table.GetType().Name.ToString()} at price of USD {setOfFurniture.Table.Price}\n" +
                   $"and {setOfChairs} chairs at USD {chairServices.GetPriceOfChairsInSet(setOfFurniture) / setOfChairs} each.\n" +
                   $"Total price for {setOfFurniture.Name} Kit is USD " +
                   $"{setOfFurniture.Table.Price + chairServices.GetPriceOfChairsInSet(setOfFurniture)}.\n");
        }
Beispiel #2
0
 public void WriteKitIntoFile(Kit kitToSave, string path)
 {
     using (StreamWriter writer = new StreamWriter(path, true, System.Text.Encoding.Default))
     {
         int    numberOfChairsInKit = ChairServices.CountChairsInKit(kitToSave);
         double totalCost           = kitToSave.Table.Price + numberOfChairsInKit * kitToSave.sampleChairOutOfList().Price;
         writer.WriteLine($"Kit of furniture {kitToSave.Name} which includes: " +
                          $"{kitToSave.Table.Size} {kitToSave.Table.GetType().Name.ToString()} made out of {kitToSave.Table.Material}" +
                          $" and {numberOfChairsInKit} {kitToSave.sampleChairOutOfList().Material} " +
                          $"chairs is ready." +
                          $"\nTotal cost for the kit is USD {totalCost}.\n");
     }
 }
Beispiel #3
0
        public void FillInKit(Kit setOfFurniture, List <Table> tables, List <Chair> chairs)
        {
            TableServices tableServices      = new TableServices();
            ChairServices chairServices      = new ChairServices();
            int           generalCounter     = 0;
            int           smallWoodTable     = tableServices.CountTablesOfEachType("wood", "small", tables);
            int           smallPlasticTable  = tableServices.CountTablesOfEachType("plastic", "small", tables);
            int           smallGlassTable    = tableServices.CountTablesOfEachType("glass", "small", tables);
            int           woodPricedChair    = chairServices.GetChairsOfOneTypeAtOnePrice("wood", chairs, setOfChairs).Count();
            int           plasticPricedChair = chairServices.GetChairsOfOneTypeAtOnePrice("plastic", chairs, setOfChairs).Count();

            Console.WriteLine("Lets build a set of furniture from what we have in stock.");
            setOfFurniture.Name = FurnitureServices.GetNameOfSet();

            if (tables.Count() == 0)
            {
                Console.WriteLine("There is no tables in stock. Unfortunatelly we can not produce any set of furniture.");
            }
            else
            {
                while (generalCounter == 0)
                {
                    tableServices.FindTable(setOfFurniture, tables);
                    setOfChairs   = chairServices.GetNumberOfChairs(setOfFurniture);
                    chairMaterial = chairServices.GetChairMaterialType(setOfFurniture);
                    IEnumerable <Chair> chairsOfOneTypeAtOnePrice = chairServices.GetChairsOfOneTypeAtOnePrice(chairMaterial, chairs, setOfChairs);

                    if (chairsOfOneTypeAtOnePrice.Count() >= setOfChairs)
                    {
                        foreach (Chair y in chairsOfOneTypeAtOnePrice)
                        {
                            generalCounter++;
                            setOfFurniture.GetList().Add(y);
                            if (setOfFurniture.GetList().Count == setOfChairs)
                            {
                                int newCounter = 0;
                                foreach (var c in setOfFurniture.GetList())
                                {
                                    chairs.Remove(c);
                                }
                                foreach (Chair x in chairs)
                                {
                                    newCounter++;
                                }
                                tables.Remove(setOfFurniture.Table);
                                break;
                            }
                        }
                        Console.WriteLine($"\n{ShowResult(setOfFurniture)}");
                    }
                    else if ((chairsOfOneTypeAtOnePrice.Count() <= setOfChairs &&
                              (chairServices.GetChairsOfOneTypeAtOnePrice("wood", chairs, setOfChairs).Count() >= 2)) && (smallWoodTable > 0 || smallGlassTable > 0))
                    {
                        Console.WriteLine("Try other combinations.");
                    }
                    else if ((chairsOfOneTypeAtOnePrice.Count() <= setOfChairs &&
                              (chairServices.GetChairsOfOneTypeAtOnePrice("plastic", chairs, setOfChairs).Count() >= 2)) && (smallPlasticTable > 0 || smallGlassTable > 0))
                    {
                        Console.WriteLine("Try other combinations.");
                    }
                    else if (woodPricedChair < 2 || (woodPricedChair < 2 && (smallWoodTable < 1 || smallGlassTable < 1)) ||
                             plasticPricedChair < 2 || (plasticPricedChair < 2 && (smallPlasticTable < 1 || smallGlassTable < 1)))
                    {
                        generalCounter--;
                        Console.WriteLine("There is not enough chairs to make any set.");
                    }
                }
            }
        }