From 40b46d7829cb48fc8cce50b7ea175795f58d6776 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Sat, 9 Dec 2023 21:18:25 -0600 Subject: [PATCH] chore: add xml comments --- 09/MirageMaintenance/Program.cs | 42 ++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/09/MirageMaintenance/Program.cs b/09/MirageMaintenance/Program.cs index be55374..8399a54 100644 --- a/09/MirageMaintenance/Program.cs +++ b/09/MirageMaintenance/Program.cs @@ -2,7 +2,7 @@ namespace MirageMaintenance; -class Program +public class Program { public static async Task Main(string[] args) { @@ -34,16 +34,34 @@ class Program } } +/// +/// Represents a report from the Oasis. +/// +/// The value histories. +/// An instance of . public class OasisReport( List valueHistories ) { + /// + /// Gets the value histories. + /// public List ValueHistories { get; init; } = valueHistories; + /// + /// Calculates the sum of all next values. + /// + /// if set to true will extrapolate next values backwards + /// The sum of all next values. public long CalculateSumOfNextValues(bool backwards = false) => ValueHistories .Select(valueHistory => valueHistory.CalculateNextValue(backwards)) .Sum(); + /// + /// Parses the specified oasis report input. + /// + /// The oasis report input. + /// An instance of . public static OasisReport Parse(string[] oasisReportInput) { var valueHistories = new List(); @@ -63,17 +81,34 @@ public class OasisReport( } } +/// +/// Represents a value history. +/// +/// The values. +/// An instance of . public class ValueHistory( List values ) { + /// + /// Gets the values. + /// List Values { get; init; } = values; + /// + /// Calculates the differences between each value. + /// + /// The values. + /// The differences between each value. public List CalculateDifferences(List values) => Enumerable .Range(0, values.Count - 1) .Select(i => values[i + 1] - values[i]) .ToList(); + /// + /// Calculates the history. + /// + /// The history. public List> CalculateHistory() { var allHistoricalValues = new List>(); @@ -92,6 +127,11 @@ public class ValueHistory( return allHistoricalValues; } + /// + /// Calculates the next value. + /// + /// if set to true will extrapolate next value backwards + /// The next value. public long CalculateNextValue(bool backwards = false) { var historicalValues = CalculateHistory();