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|"); }
public TripStatistics CalculateStatistics() { _data = DataReader.ReadData(); _statistics = new TripStatistics(); CalculateTripTime(); CalculateDistance(); CalculateTripAscent(); CalculateTripDescent(); return(_statistics); }
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(); }
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}"); } } }