-
Notifications
You must be signed in to change notification settings - Fork 0
/
jeton.cpp
47 lines (35 loc) · 953 Bytes
/
jeton.cpp
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
#include "game.h"
void addCoordonate(Jeton **jeton, int coordonate[2], char color){
Jeton *newJeton = new Jeton;
if(newJeton==0){
cout << "memory run out" << endl;
exit(1);
}
newJeton->color = color;
newJeton->coordonate[0] = coordonate[0];
newJeton->coordonate[1] = coordonate[1];
newJeton->next = NULL;
find_last(*jeton)->next = newJeton;
}
Jeton *find_last(Jeton *jeton){
while(jeton->next != NULL){
jeton=jeton->next;
}
return jeton;
}
void afficheJeton(Jeton jeton){
Jeton *current;
current = &jeton;
while(current != NULL){
cout << current->color << " les coordonnées sont " << current->coordonate[0] <<":"<< current->coordonate[1]<<endl;
current = current->next;
}
}
int countJeton(Jeton *jeton){
int nbJetons = 0;
while(jeton != NULL){
nbJetons++;
jeton = jeton->next;
}
return nbJetons;
}