-
Notifications
You must be signed in to change notification settings - Fork 0
/
affichage.cs
102 lines (94 loc) · 3.1 KB
/
affichage.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
using System;
using System.Linq;
namespace affichage{
public class Affichage{
public void header(){
Console.WriteLine("|-------------|-------|-------|-------|--------|------|------------|");
Console.WriteLine("| Période | S1 | S2 | S3 | status | tour | temps-tour |");
Console.WriteLine("|------------------------------------------------------------------|");
}
public void body(int[][] classement){
int[][] temp = CopyArray(classement);
Array.Sort(temp, new Comparison<int[]>(
(x,y) => { return x[6] < y[6] ? -1 : (x[6] > y[6] ? 1 : 0); }
));
foreach(int[] o in temp){
Console.WriteLine(information(o));
}
}
public String information(int[] o){
String s ="| Course ";
s += formatSecteur(o[2]);
s += formatSecteur(o[3]);
s += formatSecteur(o[4]);
s += formatStatus(o[5]);
s += formatTour(o[1]);
s += formatTempsTour(o[6]);
return s;
}
public bool affichage(int[][] classement){
header();
body(classement);
return true;
}
public String formatSecteur(int nbr){
String s = "";
if(nbr<10){
s += "| " + nbr+" ";
}else if(nbr<100){
s += "| " + nbr+" ";
}else if(nbr<1000){
s += "| " + nbr+" ";
}
return s;
}
public String formatTempsTour(int nbr){
String s = "";
if(nbr<1000){
s += "| " + nbr+" ";
}else if(nbr<100){
s += "| " + nbr+" ";
}else if(nbr<10){
s += "| " + nbr+" ";
}
return s;
}
public String formatStatus(int nbr){
String s = "| Stop ";
if(nbr==1){
return "| Stand ";
}
else if(nbr==2){
return "| Ready ";
}
return s;
}
public String formatTour(int nbr){
String s = "";
if((nbr%10)<10){
s += "| " + nbr+" ";
}
else {
s += "| " + nbr+" ";
}
return s;
}
public static int[][] CopyArray(int[][] source)
{
return source.Select(s => s.ToArray()).ToArray();
}
}
public class Data{
public static int[][] CopyArray(int[][] source)
{
return source.Select(s => s.ToArray()).ToArray();
}
public static int[][] getSortData(int[][] classement){
int[][] temp = CopyArray(classement);
Array.Sort(temp, new Comparison<int[]>(
(x,y) => { return x[6] < y[6] ? -1 : (x[6] > y[6] ? 1 : 0); }
));
return temp;
}
}
}