コード例 #1
0
        static void Main(string[] args)
        {
            TemperaturePredictor predictor = new TemperaturePredictor();

            predictor.Calculator = new WeatherStateCalculator();

            var temperature = predictor.PredictTemperature();

            Console.WriteLine(temperature);

            string[] config = File.ReadAllLines("config.txt", Encoding.Default);
            foreach (string logType in config)
            {
                switch (logType)
                {
                case "file":
                    predictor.Calculator = new FileLogWeatherStateCalculator(predictor.Calculator);
                    break;

                case "console":
                    predictor.Calculator = new ConsoleLogWeatherStateCalculator(predictor.Calculator);
                    break;

                default:
                    break;
                }
            }
            predictor.PredictTemperature();
            Console.ReadLine();
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: EvgenyVol/Challenge
        static void Main(string[] args)
        {
            TemperaturePredictor predictor = new TemperaturePredictor();

            predictor.Calculator = new FileLogWeatherStateCalculator(new WeatherStateCalculator());

            var temperature = predictor.PredictTemperature();

            Console.WriteLine(temperature);
        }