-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tri.cs
78 lines (68 loc) · 2.18 KB
/
Tri.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Controle10_10
{
class Tri
{
private string nature;
private Epreuve natation, velo, course;
List<Participant> lesParticipants = new List<Participant>();
public Tri(string nature, int distanceNatation, int distanceVelo, int distanceCourse)
{
this.nature = nature;
this.natation = new Epreuve("natation", distanceNatation);
this.velo = new Epreuve("velo", distanceVelo);
this.course = new Epreuve("course", distanceCourse);
this.lesParticipants = new List<Participant>();
}
public void AddParticipant(Participant unParticipant)
{
this.lesParticipants.Add(unParticipant);
}
public int GetDistanceTotale()
{
return natation.GetDistance() + velo.GetDistance() + course.GetDistance();
}
public Epreuve GetEpreuve(string nomEpreuve)
{
switch (nomEpreuve)
{
case "natation":
return this.natation;
case "vélo":
return this.velo;
default:
return this.course;
}
}
public List<Participant> GetLesTemps()
{
List<Participant> pasHorsDelai = new List<Participant>();
foreach (Participant unParticipant in lesParticipants)
{
if (unParticipant.HorsDelai() == false)
{
pasHorsDelai.Add(unParticipant);
}
}
return pasHorsDelai;
}
public string GetNature()
{
return this.nature;
}
public Participant GetParticipantById(int id)
{
foreach(Participant unParticipant in lesParticipants)
{
if (unParticipant.GetId()==id)
{
return unParticipant;
}
}
return null;
}
}
}