Пример #1
0
        private void Conclusion(Case unit)
        {
            CaseVerifier        v  = new CaseVerifier(unit);
            MotherboardVerifier mv = new MotherboardVerifier(unit.Motherboard);

            Console.WriteLine($"\nYour set:\n" +
                              $"System unit case: {unit};\n" +
                              $"PowerSupply: {unit.PowerSource}, it {CheckString(v.PowerSourceFitsCase(unit.PowerSource))} the unit case;\n" +
                              $"Motherboard: {unit.Motherboard}, it {CheckString(unit.MotherboardTypesSupported.Contains((MotherboardTypes) unit.Motherboard.Type))} the motherboard;\n" +
                              $"Processor: {unit.Motherboard.Processor}, it {CheckString(mv.ProcessorsFitsMotherboard(unit.Motherboard.Processor))} the motherboard;\n");

            Console.WriteLine($"Memory card{(unit.Motherboard.MemoryCardsAdded.Count == 1 ? "" : "s")}:");
            foreach (var s in unit.Motherboard.MemoryCardsAdded)
            {
                Console.WriteLine(
                    $"{s} - {CheckString(unit.Motherboard.MemoryCardTypesSupported.Contains((MemoryCardTypes) s.Type))}");
            }


            bool power = v.CheckPowerConsumption();

            Console.WriteLine($"battery is {(power ? "" : "not")} enough to power all the elements");
            CaseVerifier ver = new CaseVerifier(unit);

            Console.WriteLine($"\nYou can{(ver.Verify() ? "" : " not")} form a set out of these items");
            int cardsPrice = 0;

            foreach (var c in unit.Motherboard.MemoryCardsAdded)
            {
                cardsPrice += c.Price;
            }

            Console.WriteLine(
                $"Total price: {(unit.Price + unit.PowerSource.Price + unit.Motherboard.Price + unit.Motherboard.Processor.Price + cardsPrice)}");
        }
Пример #2
0
        public void ChooseItem(Items item, Case unit)
        {
            CaseVerifier        verifier            = new CaseVerifier(unit);
            MotherboardVerifier motherboardVerifier = new MotherboardVerifier(unit.Motherboard);

            switch (item)
            {
            case Items.MOTHERBOARD:
                CheckFunction <Motherboard> checkMoth = verifier.MotherboardFitsCase;
                configurator.Choose(Motherboards.FindAll(), Items.MOTHERBOARD, unit, checkMoth);
                break;

            case Items.POWER_SOURCE:
                CheckFunction <PowerSource> checkPow = verifier.PowerSourceFitsCase;
                configurator.Choose(PowerSources.FindAll(), Items.POWER_SOURCE, unit, checkPow);
                break;

            case Items.PROCESSOR:
                CheckFunction <Processor> checkProc =
                    motherboardVerifier.ProcessorsFitsMotherboard;
                configurator.Choose(Processors.FindAll(), Items.PROCESSOR, unit, checkProc);
                break;

            case Items.MEMORY_CARD:
                CheckFunction <MemoryCard> checkMemory =
                    motherboardVerifier.MemoryCardFitsMotherBoard;
                configurator.ChooseMultiple(unit, unit.Motherboard.MemoryCardsAdded, MemoryCards.FindAll(),
                                            Items.MEMORY_CARD,
                                            checkMemory);
                break;
            }
        }
Пример #3
0
        public void Init(ControllerTerminal controllerTerminal, ModelImpl model)
        {
            _controllerTerminal = controllerTerminal;
            _model = model;
            _unit  = _model.configurator.unit;

            // Console.WriteLine("Please, choose a system unit case");
            ChooseItem(Items.CASE);


            bool loopmenu = true;

            while (loopmenu)
            {
                Console.WriteLine("Press:\n" +
                                  "1 - to choose motherboard\n" +
                                  "2 - to choose power supply\n" +
                                  "3 - to choose processor\n" +
                                  "4 - to choose memory card\n" +
                                  "C - to get conclusion");


                var                 inputKey            = Console.ReadKey().Key;
                CaseVerifier        verifier            = new CaseVerifier(_unit);
                MotherboardVerifier motherboardVerifier = new MotherboardVerifier(_unit.Motherboard);
                loopmenu = _controllerTerminal.Switcher(inputKey);
            }
        }