-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOrganisme.java
More file actions
executable file
·45 lines (37 loc) · 1.07 KB
/
Organisme.java
File metadata and controls
executable file
·45 lines (37 loc) · 1.07 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
package TP_Pois_Mendel;
// Cette classe décrit un organisme diploïde, qui a un nom et un phénotype
public class Organisme {
protected String nom;
protected Phenotype phenotype;
// Constructeur
public Organisme() {}
public Organisme(String nom, Phenotype phenotype) {
this.nom = nom;
this.phenotype = phenotype;
}
// Getters
public String getNom() {
return nom;
}
public Phenotype getPhenotype() {
return phenotype;
}
// Afficher
void afficher() {
System.out.println("Organisme : " + getNom());
phenotype.afficher();
}
public static void main (String[] args) {
Gene gene1 = new Gene("Couleur", 'J');
Gene gene2 = new Gene("Couleur", 'v');
Caractere couleur = new Caractere("Couleur", gene1, gene2, "jaune", "vert");
Gene gene3 = new Gene("Aspect", 'L');
Gene gene4 = new Gene("Aspect", 'r');
Caractere aspect = new Caractere("Aspect", gene3, gene4, "lisse", "rugueux");
Phenotype pheno = new Phenotype();
pheno.addCaractere(couleur);
pheno.addCaractere(aspect);
Organisme orga = new Organisme("Bestiole", pheno);
orga.afficher();
}
}