aboutsummaryrefslogtreecommitdiff
path: root/semestre 4/java/tme/tp1/Villageois.java
diff options
context:
space:
mode:
authorAnhgelus Morhtuuzh <william@herges.fr>2026-02-02 10:35:57 +0100
committerAnhgelus Morhtuuzh <william@herges.fr>2026-02-02 10:35:57 +0100
commitba6692d9b508b448eafd7bc71faa4ae3f3ac7199 (patch)
tree93212290628cd6e62245328c7c9bade60ea16813 /semestre 4/java/tme/tp1/Villageois.java
parent7cacc4323027307aaa16f4d75a1e2ed4bf8362ff (diff)
Cours du 26 au 30 janvier
Diffstat (limited to 'semestre 4/java/tme/tp1/Villageois.java')
-rw-r--r--semestre 4/java/tme/tp1/Villageois.java23
1 files changed, 23 insertions, 0 deletions
diff --git a/semestre 4/java/tme/tp1/Villageois.java b/semestre 4/java/tme/tp1/Villageois.java
new file mode 100644
index 0000000..35dd819
--- /dev/null
+++ b/semestre 4/java/tme/tp1/Villageois.java
@@ -0,0 +1,23 @@
+public class Villageois {
+ private String nom;
+ private double poids;
+ private boolean malade;
+
+ public Villageois(String nom) {
+ this.nom = nom;
+ this.poids = Math.random() * (150-50)+50;
+ this.malade = Math.random() < 0.2;
+ }
+
+ public String getNom() { return nom; }
+ public double getPoids() { return poids; }
+ public boolean getMalade() { return malade; }
+
+ public double poidsSouleve() {
+ return malade ? (double) 1/3 * poids : (double) 1/4 * poids;
+ }
+
+ public String toString() {
+ return String.format("Villageois [%s, %.2f, %b, %.2f]", nom, poids, malade, poidsSouleve());
+ }
+}