-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGene.java
More file actions
executable file
·55 lines (47 loc) · 1.23 KB
/
Gene.java
File metadata and controls
executable file
·55 lines (47 loc) · 1.23 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
package TP_Pois_Mendel;
// Cette classe représente un gène qui n'a que deux allèles
public class Gene {
private String nom;
private char allele;
private boolean estDominant;
// Constructeurs
public Gene() {}
public Gene(String nom, char allele) {
this.nom = nom;
this.allele = allele;
estDominant = estDominant();
/* On utilise dans le constructeur la méthode qui définit si un allèle est dominant :
- pas de risque de se tromper
- On instancie les gènes uniquement avec leur nom et leur allèle
*/
}
// Getters
public String getNom() {
return nom;
}
public char getAllele() {
return allele;
}
public boolean getEstDominant() {
return estDominant;
}
// Détermine si un allèle est dominant ou récessif
public boolean estDominant() {
if (allele > 'A' && allele < 'Z') {
return true;
} else {
return false;
}
}
// Affiche les attributs du gene
void afficher() {
System.out.println("Gene : " + this.getNom() + " - Allele : " + this.getAllele() + " - Dominant : " + this.getEstDominant());
}
public static void main (String[] args) {
// Test
Gene gene1 = new Gene("Couleur", 'J');
Gene gene2 = new Gene("Couleur", 'v');
gene1.afficher();
gene2.afficher();
}
}