public void GivePoints(LinkedList <Driver> eindstand) //takes the list of finished drivers and makes DriverPoints objects, { //allocates points and adds them to the List<T> //List<IDataTemplate> list = new List<IDataTemplate>(); int x = eindstand.Count; for (int i = 0; i < x; i++) { DriverPoints ptsdriver = new DriverPoints(); ptsdriver.Name = eindstand.First.Value.Name; eindstand.RemoveFirst(); //x--; if (i == 0) { ptsdriver.Points = 3; } if (i == 1) { ptsdriver.Points = 2; } if (i >= 2) { ptsdriver.Points = 1; } DriverPoints.AddItemToList(ptsdriver); } }
public void DisplayBestDriverData() { Console.SetCursorPosition(0, 40); Console.WriteLine($"Coureur met de meeste punten : {DriverPoints.GetBestDriverName()}"); Console.WriteLine($"Coureur met de snelste tijd : {DriverLapTime.GetBestDriverName()}"); //laptime //points }
public string GetBestDriverName(List <IDataTemplate> list) // IN POINTS { DriverPoints bestedriver = new DriverPoints(); foreach (DriverPoints driver in list) { if (driver.Points > bestedriver.Points) { bestedriver = driver; } } return(bestedriver.Name); }
public string GetBest <T>(List <T> list) where T : class, IDriverName { int highestPoints = 0; DriverPoints DriverPoints = this; foreach (var driver in list) { var currentDriver = driver as DriverPoints; if (currentDriver.Points > highestPoints) { highestPoints = currentDriver.Points; DriverPoints = currentDriver; } } return(DriverPoints.Name); }
//add points to the drivers based on dictionary with key as finish position public void AddPointsToDirvers(Dictionary <int, string> FinishPosition) { int points = 0; foreach (KeyValuePair <int, string> position in FinishPosition) { switch (position.Key) { case 1: points = 25; break; case 2: points = 20; break; case 3: points = 18; break; case 4: points = 15; break; case 5: points = 10; break; case 6: points = 5; break; default: points = 0; break; } DriverPoints.AddItemToList(new DriverPoints(position.Value, points)); } }