Exemplo n.º 1
0
        public static void GetSimpleExample()
        {
            var dollarClient = new DollarClient();
            var euroClient   = new EuroClient();

            Console.WriteLine("Получаем значения из двух клиентов:");

            var dollarAmount = dollarClient.GetTotalAmount();
            var euroAmount   = euroClient.GetEuroSum();

            Console.WriteLine($"dollarClient.GetTotalAmount: {dollarAmount}");
            Console.WriteLine($"euroClient.GetEuroSum: {euroAmount}");

            Console.WriteLine($"Используем конвертеры для преобразования в рубли:");

            var dollarsInRubles = ConvertDollarsToRubles(dollarAmount);
            var euroInRubles    = ConvertEuroToRubles(euroAmount);

            Console.WriteLine($"ConvertDollarsToRubles(dollarAmount): {dollarsInRubles}");
            Console.WriteLine($"ConvertEuroToRubles(euroAmount): {euroInRubles}");

            Console.WriteLine($"Вызываем сервисный метод:");
            var rubleService = new RubleService();

            rubleService.ReceiveReportInRubles(dollarsInRubles);
            rubleService.ReceiveReportInRubles(euroInRubles);
        }
Exemplo n.º 2
0
        public static void GetPatternExample()
        {
            Console.WriteLine("Вызываем адаптер:");

            var moneyAdapter            = new MoneyAdapter();
            var rublesAmountFromDollars = moneyAdapter.GetRublesAmountFromDollars();
            var rublesAmountFromEuros   = moneyAdapter.GetRublesAmountFromEuros();

            Console.WriteLine($"moneyAdapter.GetRublesAmountFromDollars: {rublesAmountFromDollars}");
            Console.WriteLine($"moneyAdapter.GetRublesAmountFromEuros {rublesAmountFromEuros}");

            Console.WriteLine("Вызываем сервисный метод:");

            var rubleService = new RubleService();

            rubleService.ReceiveReportInRubles(rublesAmountFromDollars);
            rubleService.ReceiveReportInRubles(rublesAmountFromEuros);
        }