diff --git a/Marathons/Marathon.cs b/Marathons/Marathon.cs index c666b2c..b52fc85 100644 --- a/Marathons/Marathon.cs +++ b/Marathons/Marathon.cs @@ -1,3 +1,35 @@ namespace Marathons; -// TODO \ No newline at end of file +public sealed class Marathon +{ + //private Node? _head; + public readonly string City; + public readonly DateOnly Date; + public int ParticipantCount { get; private set; } + + public Marathon(string city, DateOnly date) + { + City = city; + Date = date; + } + + public void AddParticipant(Participant participant) + { + + } + + public bool RemoveParticipant(int index) + { + return false; + } + + public string[] GetResultList() + { + return Array.Empty(); + } + + public override string ToString() + { + return $"{City} marathon on {Date.ToString()}"; + } +} \ No newline at end of file diff --git a/Marathons/Node.cs b/Marathons/Node.cs new file mode 100644 index 0000000..a10214f --- /dev/null +++ b/Marathons/Node.cs @@ -0,0 +1,7 @@ +namespace Marathons; + +public sealed class Node(double? value) +{ + public double? Data { get; } = value; + public Node? Next { get; set; } +} diff --git a/Marathons/Participant.cs b/Marathons/Participant.cs index c666b2c..72866ff 100644 --- a/Marathons/Participant.cs +++ b/Marathons/Participant.cs @@ -1,3 +1,37 @@ namespace Marathons; -// TODO \ No newline at end of file +public sealed class Participant +{ + public readonly int StartNo; + public readonly string Name; + public readonly TimeSpan CompletionTime; + + public Participant(int startNo, string name, TimeSpan completionTime) + { + StartNo = startNo; + Name = name; + CompletionTime = completionTime; + } + + public int CompareTo(Participant participant) + { + // Check if the completion time and startno is the same + if (CompletionTime == participant.CompletionTime && StartNo == participant.StartNo) + { + return 0; + } + + // Check if the completion time is the same + if(CompletionTime == participant.CompletionTime) + { + return StartNo < participant.StartNo ? -1 : 1; + } + + return CompletionTime < participant.CompletionTime ? -1 : 1; + } + + public override string ToString() + { + return $"{Name} (Start# {StartNo:000}) finished in {CompletionTime}"; + } +} \ No newline at end of file