-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHumain.cpp
More file actions
88 lines (68 loc) · 2 KB
/
Copy pathHumain.cpp
File metadata and controls
88 lines (68 loc) · 2 KB
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
#include "Humain.h"
#include "Gene.h"
#include <stdio.h>
//Creaters
Humain Humain::createFromReproduce(Humain* theMother, Humain* theFather) {
lastGene=-1;
int i;
mother = theMother;
father = theFather;
for(i = 0; i <= theMother->lastGene; i++) {
Gene childGene;
/* Le code suivant est lisible, mais le code utilisé sera celui d'après car il est plus rapide
motherGenes[0] = theMother->genes[i].alleleL();
motherGenes[1] = theMother->genes[i].alleleR();
int fatherGenes[2];
fatherGenes[0] = theFather->genes[i].alleleL();
fatherGenes[1] = theFather->genes[i].alleleR();
childGene.createFromParents(motherGenes, fatherGenes); // parameters Mother[], Father[]*/
int motherGenes[2] = {theMother->genes[i].alleleL(),theMother->genes[i].alleleR()};
int fatherGenes[2] = {theFather->genes[i].alleleL(),theFather->genes[i].alleleR()};
childGene.createFromParents(motherGenes, fatherGenes);
setNextGene(childGene);
}
return *this;
}
//sorter
//printer
void Humain::printGene(int i) {
printf("Gene n°%d : TYPE %d ; DOMINANT : %d ; ALLELE_D : %d\n", i, genes[i].type_id, genes[i].speaking(), genes[i].alleleR());
}
void Humain::printSexe() {
if(genes[0].speaking() == 1) {
printf("HOMME");
}
else {
printf("FEMME");
}
}
//getter
//setter
int Humain::setNextGene(Gene g) {
genes[lastGene+1] = g;
lastGene++;
return lastGene;
}
//tester
bool Humain::isMyParent(Humain* parent) {
return ((father == parent) || (mother == parent));
}
//Class Methods
Humain Humain::reproduce(Humain* pere) { //Fonction obsolète
int i;
Humain child;
child.mother = this;
child.father = pere;
for(i = 0; i <= lastGene; i++) {
Gene childGene;
int motherGenes[2];
motherGenes[0] = genes[i].alleleL();
motherGenes[1] = genes[i].alleleR();
int fatherGenes[2];
fatherGenes[0] = pere->genes[i].alleleL();
fatherGenes[1] = pere->genes[i].alleleR();
childGene.createFromParents(motherGenes, fatherGenes); // parameters Mother[], Father[]
child.setNextGene(childGene);
}
return child;
}