コード例 #1
0
 public void PrintStatistics(TripStatistics data)
 {
     Console.WriteLine($"_____________________________________");
     Console.WriteLine($"|Parameter     |Value      |Unit    |");
     Console.WriteLine($"_____________________________________");
     Console.WriteLine($"|Trip time     |{data.TripTime}| hh:mm:ss|");
     Console.WriteLine($"|Ascent        |{data.Ascent}  | m|");
     Console.WriteLine($"|Descent       |{data.Descent} | m|");
 }
コード例 #2
0
        public TripStatistics CalculateStatistics()
        {
            _data       = DataReader.ReadData();
            _statistics = new TripStatistics();
            CalculateTripTime();
            CalculateDistance();
            CalculateTripAscent();
            CalculateTripDescent();

            return(_statistics);
        }
コード例 #3
0
        static void Main(string[] args)
        {
            IBikeDataReader dataReader = new XmlDataReader();

            StatisticManager manager = new StatisticManager(dataReader);

            TripStatistics statistics = manager.CalculateStatistics();

            IStatisticPresenter presenter = new FileStatisticPresenter();

            presenter.PrintStatistics(statistics);


            Console.ReadKey();
        }
コード例 #4
0
        public void PrintStatistics(TripStatistics data)
        {
            string path = "statistics.txt";

            if (!File.Exists(path))
            {
                // Create a file to write to.
                using (StreamWriter sw = File.CreateText(path))
                {
                    sw.WriteLine($"Trip Time: {data.TripTime}");
                    sw.WriteLine($"Trip Distance: {data.Distance}");
                    sw.WriteLine($"Trip Ascent: {data.Ascent}");
                    sw.WriteLine($"Trip Descent: {data.Descent}");
                }
            }
        }