예제 #1
0
 public override void AddCash(CopyMachine copyMachine)
 {
     ConsolePrintHelper.WriteLineLabel("Добро пожаловать!");
     ConsolePrintHelper.WriteLabel("Цена одной страницы : ");
     ConsolePrintHelper.WriteLineValue(copyMachine.CostOfPage.ToString());
     ConsolePrintHelper.WriteLineLabel("Внесите сумму:");
     copyMachine.Cash  = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);
     copyMachine.State = new ChooseDeviceState();
     copyMachine.State.ChooseDevice(copyMachine);
 }
            public override void ChooseDevice(CopyMachine copyMachine)
            {
                ConsolePrintHelper.WriteLineLabel("Выберите устройство:");
                foreach (var device in Program.Devices)
                {
                    ConsolePrintHelper.WriteLabel($"{nameof(device.Id)} : ");
                    ConsolePrintHelper.WriteValue(device.Id.ToString());
                    ConsolePrintHelper.WriteLabel("; ");
                    ConsolePrintHelper.WriteLabel($"{nameof(device.Name)} : ");
                    ConsolePrintHelper.WriteLineValue(device.Name);
                }
                var deviceId = int.Parse(Console.ReadLine());

                copyMachine.Device = Program.Devices.First(i => i.Id == deviceId);
                copyMachine.State  = new ChooseDocumentState();
                copyMachine.State.ChooseDocument(copyMachine);
            }
            public override void ChooseDocument(CopyMachine copyMachine)
            {
                ConsolePrintHelper.WriteLineLabel("Выберите документ:");
                foreach (var document in copyMachine.Device.Documents)
                {
                    ConsolePrintHelper.WriteLabel($"{nameof(document.Id)} : ");
                    ConsolePrintHelper.WriteValue(document.Id.ToString());
                    ConsolePrintHelper.WriteLabel("; ");
                    ConsolePrintHelper.WriteLabel($"{nameof(document.Name)} : ");
                    ConsolePrintHelper.WriteLineValue(document.Name);
                }
                var documentId = int.Parse(Console.ReadLine());

                copyMachine.Document = copyMachine.Device.Documents.First(i => i.Id == documentId);
                copyMachine.State    = new PrintDocumentState();
                copyMachine.State.PrintDocument(copyMachine);
            }
            public override void AskTheQuestion(CopyMachine copyMachine)
            {
                ConsolePrintHelper.WriteLineLabel("Хотите распечатать еще документ?");
                ConsolePrintHelper.WriteLabel("1 : ");
                ConsolePrintHelper.WriteLineValue("Да");
                ConsolePrintHelper.WriteLabel("2 : ");
                ConsolePrintHelper.WriteLineValue("Нет");

                var result = int.Parse(Console.ReadLine());

                if (result == 1)
                {
                    copyMachine.State = new ChooseDocumentState();
                    copyMachine.State.ChooseDocument(copyMachine);
                    return;
                }
                copyMachine.State = new ReturnDeliveryState();
                copyMachine.State.ReturnDelivery(copyMachine);
            }