summaryrefslogtreecommitdiff
path: root/sem_4/java/eclipse-workspace/Laponie/src
diff options
context:
space:
mode:
authorGaspard Coulet <gaspard.coulet@mines-ales.org>2021-04-28 23:05:53 +0200
committerGaspard Coulet <gaspard.coulet@mines-ales.org>2021-04-28 23:05:53 +0200
commit9fe033ea88c2f705ec18c232873d056e0c229d72 (patch)
tree0647dc8c51610c7336c88c04de2068ea14b21e17 /sem_4/java/eclipse-workspace/Laponie/src
Initial commit
Diffstat (limited to 'sem_4/java/eclipse-workspace/Laponie/src')
-rw-r--r--sem_4/java/eclipse-workspace/Laponie/src/Colis.java51
-rw-r--r--sem_4/java/eclipse-workspace/Laponie/src/Lettre.java43
-rw-r--r--sem_4/java/eclipse-workspace/Laponie/src/Objpostal.java76
-rw-r--r--sem_4/java/eclipse-workspace/Laponie/src/Sacpostal.java49
4 files changed, 219 insertions, 0 deletions
diff --git a/sem_4/java/eclipse-workspace/Laponie/src/Colis.java b/sem_4/java/eclipse-workspace/Laponie/src/Colis.java
new file mode 100644
index 0000000..26e5dfd
--- /dev/null
+++ b/sem_4/java/eclipse-workspace/Laponie/src/Colis.java
@@ -0,0 +1,51 @@
+
+public class Colis extends Objpostal{
+ private String contenu;
+ private double valeurdec;
+ public double tarifaff() {
+ double ret = 2;
+ int tmp = super.tauxrecommand();
+ if ( tmp >= 1 ) {
+ ret += 0.5;
+ }
+ if ( tmp >= 2) {
+ ret += 1.5;
+ }
+ if ( super.getVol()> (1/8)) {
+ ret += 3;
+ }
+ return ret;
+ }
+ protected String getContenu() {
+ return contenu;
+ }
+ protected void setContenu(String contenu) {
+ this.contenu = contenu;
+ }
+ protected double getValeurdec() {
+ return valeurdec;
+ }
+ protected void setValeurdec(double valeurdec) {
+ this.valeurdec = valeurdec;
+ }
+ public double tauxremboursement () {
+ double ret = 0;
+ int tmp = super.tauxrecommand();
+ if ( tmp == 1 ) {
+ ret += 0.1 * this.valeurdec;
+ }
+ else if ( tmp == 2) {
+ ret += 0.5 * this.valeurdec;
+ }
+ super.setTauxRemboursement(ret);
+ return ret;
+ }
+ public void tostring() {
+ System.out.println(super.getCodepost()+"/"+super.getDestination()+"/"+super.getTauxrecommand()+"/"+super.getVol()+"/"+this.valeurdec);
+ }
+ public Colis (String ext_origin, String ext_dest, int ext_codepost, double ext_poid, double ext_volume, int ext_tauxrec, String ext_contenu, double ext_value ) {
+ super(ext_origin, ext_dest, ext_codepost, ext_poid, ext_volume, ext_tauxrec);
+ this.setContenu(ext_contenu);
+ this.setValeurdec(ext_value);
+ }
+}
diff --git a/sem_4/java/eclipse-workspace/Laponie/src/Lettre.java b/sem_4/java/eclipse-workspace/Laponie/src/Lettre.java
new file mode 100644
index 0000000..2b30991
--- /dev/null
+++ b/sem_4/java/eclipse-workspace/Laponie/src/Lettre.java
@@ -0,0 +1,43 @@
+
+public class Lettre extends Objpostal {
+ private boolean urgent;
+ public double tarifaff() {
+ double ret = 0.5;
+ int tmp = super.tauxrecommand();
+ if ( tmp >= 1 ) {
+ ret += 0.5;
+ }
+ if ( tmp >= 2) {
+ ret += 1.5;
+ }
+ if ( urgent) {
+ ret += 0.3;
+ }
+ return ret;
+ }
+ public double tauxremboursement () {
+ double ret = 0;
+ int tmp = super.tauxrecommand();
+ if ( tmp == 1 ) {
+ ret += 1.5;
+ }
+ else if ( tmp == 2) {
+ ret += 15;
+ }
+ super.setTauxRemboursement(ret);
+ return ret;
+ }
+ public void tostring() {
+ System.out.println(super.getCodepost()+"/"+super.getDestination()+"/"+super.tauxrecommand()+"/"+(this.urgent ? "urgent":"ordinaire"));
+ }
+ public Lettre (String ext_origin, String ext_dest, int ext_codepost, double ext_poid, double ext_volume, int ext_tauxrec, boolean ext_urgent) {
+ super(ext_origin, ext_dest, ext_codepost, ext_poid, ext_volume, ext_tauxrec);
+ this.setUrgent(ext_urgent);
+ }
+ protected boolean isUrgent() {
+ return urgent;
+ }
+ protected void setUrgent(boolean urgent) {
+ this.urgent = urgent;
+ }
+}
diff --git a/sem_4/java/eclipse-workspace/Laponie/src/Objpostal.java b/sem_4/java/eclipse-workspace/Laponie/src/Objpostal.java
new file mode 100644
index 0000000..384438f
--- /dev/null
+++ b/sem_4/java/eclipse-workspace/Laponie/src/Objpostal.java
@@ -0,0 +1,76 @@
+
+public abstract class Objpostal {
+ private String origine;
+ private String destination;
+ private int codepost;
+ private double poids;
+ private double vol;
+ private int tauxrecommand;
+ private double tauxremboursement;
+ protected void setTauxRemboursement (double taux ) {
+ tauxremboursement = taux;
+ }
+ protected double getTauxRemboursement () {
+ return tauxremboursement;
+ }
+
+ public int tauxrecommand () {
+ return this.tauxrecommand;
+ }
+
+ protected String getOrigine() {
+ return origine;
+ }
+
+ protected void setOrigine(String origine) {
+ this.origine = origine;
+ }
+
+ protected String getDestination() {
+ return destination;
+ }
+
+ protected void setDestination(String destination) {
+ this.destination = destination;
+ }
+
+ protected int getCodepost() {
+ return codepost;
+ }
+
+ protected void setCodepost(int codepost) {
+ this.codepost = codepost;
+ }
+
+ protected double getPoids() {
+ return poids;
+ }
+
+ protected void setPoids(double poids) {
+ this.poids = poids;
+ }
+
+ protected double getVol() {
+ return vol;
+ }
+
+ protected void setVol(double vol) {
+ this.vol = vol;
+ }
+
+ protected int getTauxrecommand() {
+ return tauxrecommand;
+ }
+
+ protected void setTauxrecommand(int tauxrecommand) {
+ this.tauxrecommand = tauxrecommand;
+ }
+ public Objpostal (String ext_origin, String ext_dest, int ext_codepost, double ext_poid, double ext_volume, int ext_tauxrec) {
+ this.setOrigine(ext_origin);
+ this.setDestination(ext_dest);
+ this.setCodepost(ext_codepost);
+ this.setPoids(ext_poid);
+ this.setVol(ext_volume);
+ this.setTauxrecommand(ext_tauxrec);
+ }
+}
diff --git a/sem_4/java/eclipse-workspace/Laponie/src/Sacpostal.java b/sem_4/java/eclipse-workspace/Laponie/src/Sacpostal.java
new file mode 100644
index 0000000..86b7f0f
--- /dev/null
+++ b/sem_4/java/eclipse-workspace/Laponie/src/Sacpostal.java
@@ -0,0 +1,49 @@
+import java.util.ArrayList;
+
+public class Sacpostal {
+ private ArrayList<Objpostal> listeobj;
+ private double sizemax;
+ private double occupation;
+ private double valeurrefund;
+
+ public Sacpostal () {
+ occupation = 5;
+ sizemax=500;
+ listeobj = new ArrayList<Objpostal>();
+ }
+ public Sacpostal (double taille) {
+ occupation = 5;
+ sizemax=taille;
+ listeobj = new ArrayList<Objpostal>();
+ }
+
+ public double getOccupation () {
+ return occupation;
+ }
+ public void addObject(Objpostal obj) {
+ if (sizemax > occupation+ obj.getVol()) {
+ listeobj.add(obj);
+ occupation+=obj.getVol();
+ valeurrefund+= obj.getTauxRemboursement();
+ }
+ }
+ public void removeObject(Objpostal obj) {
+ if (listeobj.remove(obj)) {
+ occupation -=obj.getVol();
+ valeurrefund -= obj.getTauxRemboursement();
+ }
+ }
+ public double getRefund () {
+ return valeurrefund;
+ }
+ public void extractToo (Sacpostal cible, int codepost) {
+ for (int i =0 ; i < listeobj.size(); i ++) {
+ if (listeobj.get(i).getCodepost()==codepost) {
+ cible.addObject(listeobj.get(i));
+ removeObject(listeobj.get(i));
+ }
+ }
+ }
+
+ }
+