public string GetLeaderboard()
    {
        StringBuilder sb = new StringBuilder();

        sb.Append("Lap ");
        sb.Append(CurrentLap.ToString());
        sb.Append("/");
        sb.AppendLine(LapsNumber.ToString());

        int position = 1;

        foreach (Driver driver in Drivers.OrderBy(x => x.TotalTime))
        {
            sb.AppendFormat($"{position} {driver.Name} ");
            sb.AppendFormat($"{driver.TotalTime:f3}" + Environment.NewLine);

            position++;
        }

        foreach (Driver driver in FailedDrivers)
        {
            sb.AppendFormat($"{position} {driver.Name} ");
            sb.AppendLine(driver.FailureReason + Environment.NewLine);
            position++;
        }

        return(sb.ToString());
    }
Beispiel #2
0
    public string GetLeaderboard()
    {
        var leaderBoardSB = new StringBuilder();

        leaderBoardSB.Append($"Lap {CurrentLap}/{LapsNumber}").AppendLine();
        int standingCounter = 1;

        foreach (var driver in Drivers.OrderBy(d => d.IsDnf).ThenBy(d => d.TotalTime))
        {
            leaderBoardSB.Append($"{standingCounter} {driver}").AppendLine();
            standingCounter++;
        }
        return(leaderBoardSB.ToString().Trim());
    }
Beispiel #3
0
    private string GetWinner()
    {
        Driver winner = Drivers.OrderBy(d => d.Value.TotalTime).First().Value;

        return($"{winner.Name} wins the race for {winner.TotalTime:f3} seconds.");
    }
Beispiel #4
0
 public IEnumerable <Driver> OrderDriversByNumberPlate()
 {
     return(Drivers.OrderBy(d => d.NumberPlateInt));
 }