diff --git a/src/tpOO/tp07/BreedingFarm.java b/src/tpOO/tp07/BreedingFarm.java new file mode 100644 index 0000000000000000000000000000000000000000..d5e23c29716e605cfe5b12d93dc72f1dab044a98 --- /dev/null +++ b/src/tpOO/tp07/BreedingFarm.java @@ -0,0 +1,5 @@ +package tpOO.tp07; + +public class BreedingFarm { + +} diff --git a/src/tpOO/tp07/Duck.java b/src/tpOO/tp07/Duck.java new file mode 100644 index 0000000000000000000000000000000000000000..53d7c8c8ed6cc4a823f0b07a38ac3debedb8aabb --- /dev/null +++ b/src/tpOO/tp07/Duck.java @@ -0,0 +1,12 @@ +package tpOO.tp07; + +public class Duck extends Poultry{ + + public static double priceKg = 1.5; + public static double slaughterTreshold = 5.0; + + Duck(int identity, double weight){ + super(identity, weight); + this.type = "Duck"; + } +} diff --git a/src/tpOO/tp07/Goose.java b/src/tpOO/tp07/Goose.java new file mode 100644 index 0000000000000000000000000000000000000000..a926f854f761ddfc531c990c15446f3b14deab19 --- /dev/null +++ b/src/tpOO/tp07/Goose.java @@ -0,0 +1,12 @@ +package tpOO.tp07; + +public class Goose extends Poultry{ + + public static double priceKg = 4.0; + public static double slaughterTreshold = 10.0; + + Goose(int identity, double weight){ + super(identity, weight); + this.type = "Goose"; + } +} diff --git a/src/tpOO/tp07/Hen.java b/src/tpOO/tp07/Hen.java new file mode 100644 index 0000000000000000000000000000000000000000..da078e84867da65ee29c829619b51f4d288d5164 --- /dev/null +++ b/src/tpOO/tp07/Hen.java @@ -0,0 +1,11 @@ +package tpOO.tp07; + +public class Hen extends Poultry{ + public static double priceKg = 1.0; + public static double slaughterTreshold = 3.5; + + Hen(int identity, double weight){ + super(identity, weight); + this.type = "Hen"; + } +} diff --git a/src/tpOO/tp07/IForceFeeding.java b/src/tpOO/tp07/IForceFeeding.java new file mode 100644 index 0000000000000000000000000000000000000000..4f2438410ba78ba7e73217c99e01cca2a60fc83a --- /dev/null +++ b/src/tpOO/tp07/IForceFeeding.java @@ -0,0 +1,5 @@ +package tpOO.tp07; + +public interface IForceFeeding { + +} diff --git a/src/tpOO/tp07/Poultry.java b/src/tpOO/tp07/Poultry.java new file mode 100644 index 0000000000000000000000000000000000000000..de60a3c2ac9aa5f8af4e1408927cbfbd342cab47 --- /dev/null +++ b/src/tpOO/tp07/Poultry.java @@ -0,0 +1,43 @@ +package tpOO.tp07; + +public class Poultry { + protected int identity; + protected double weight; + String type; + + protected Poultry(int identity, double weight){ + this.identity = identity; + this.weight = weight; + } + + public int getIdentity(){ + return this.identity; + } + + public void setIdentity(int identity){ + this.identity=identity; + } + + public double getWeight(){ + return this.weight; + } + + public double getPrice(){ + if(this.type=="Hen"){ + return Hen.priceKg * this.weight; + } + if(this.type=="Duck"){ + return Duck.priceKg * this.weight; + } + return Goose.priceKg * this.weight; + } + + public void setWeight(double weight){ + this.weight = weight; + } + + @Override + public String toString(){ + return this.type + " [" + this.identity + ", " + this.weight + "]"; + } +}