Initialized class + working Participant.cs class
This commit is contained in:
parent
56839b6aef
commit
79dfde3aa1
3 changed files with 75 additions and 2 deletions
|
|
@ -1,3 +1,35 @@
|
|||
namespace Marathons;
|
||||
|
||||
// TODO
|
||||
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<string>();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{City} marathon on {Date.ToString()}";
|
||||
}
|
||||
}
|
||||
7
Marathons/Node.cs
Normal file
7
Marathons/Node.cs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
namespace Marathons;
|
||||
|
||||
public sealed class Node(double? value)
|
||||
{
|
||||
public double? Data { get; } = value;
|
||||
public Node? Next { get; set; }
|
||||
}
|
||||
|
|
@ -1,3 +1,37 @@
|
|||
namespace Marathons;
|
||||
|
||||
// TODO
|
||||
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}";
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue