From eefa29173ab59f1368d4988fa78cf024ea3b86ee Mon Sep 17 00:00:00 2001
From: Samuel Turpin <samuel.turpin.etu@univ-lille.fr>
Date: Wed, 10 Apr 2024 16:28:58 +0200
Subject: [PATCH] tp6 presque fini

---
 src/tp06/Car.java                   | 78 +++++++++++++++++++++++++++
 src/tp06/Company.java               | 81 +++++++++++++++++++++++++++++
 src/tp06/Employee.java              | 37 +++++++++++++
 src/tp06/Salesperson.java           | 35 +++++++++++++
 src/tp06/TravellingSalesperson.java | 26 +++++++++
 src/tp06/Vendor.java                | 26 +++++++++
 src/tp06/Worker.java                | 43 +++++++++++++++
 7 files changed, 326 insertions(+)
 create mode 100644 src/tp06/Car.java
 create mode 100644 src/tp06/Company.java
 create mode 100644 src/tp06/Employee.java
 create mode 100644 src/tp06/Salesperson.java
 create mode 100644 src/tp06/TravellingSalesperson.java
 create mode 100644 src/tp06/Vendor.java
 create mode 100644 src/tp06/Worker.java

diff --git a/src/tp06/Car.java b/src/tp06/Car.java
new file mode 100644
index 0000000..ba2e516
--- /dev/null
+++ b/src/tp06/Car.java
@@ -0,0 +1,78 @@
+package tp06;
+
+import java.time.LocalDate;
+
+public class Car
+{
+    private double temporalDropRate;
+    private double mileageDropRate;
+    private String brand;
+    private LocalDate onRoad;
+    private double purchasePrice;
+    private LocalDate onSale;
+    private double salePrice;
+    private int mileage;
+
+    public Car(String brand, LocalDate onRoad, double pPrice, LocalDate onSale, double sPrice, int km)
+    {
+        this.brand=brand;
+        this.onRoad=onRoad;
+        this.purchasePrice=pPrice;
+        this.onSale=onSale;
+        this.salePrice=sPrice;
+        this.mileage=km;
+    }
+
+    public Car(String brand, LocalDate onRoad, double pPrice, int km)
+    {
+        this.brand=brand;
+        this.onRoad=onRoad;
+        this.purchasePrice=pPrice;
+        this.mileage=km;
+        this.salePrice=pPrice;
+        this.onSale=LocalDate.now();
+    }
+
+    public String getBrand()
+    {
+        return brand;
+    }
+
+    public int getMileage()
+    {
+        return mileage;
+    }
+   
+    public LocalDate getOnRoad()
+    {
+        return onRoad;
+    }
+
+    public LocalDate getOnSale()
+    {
+        return onSale;
+    }
+
+    public double getPurchasePrice()
+    {
+        return purchasePrice;
+    }
+
+    public void setSalePrice(double salePrice)
+    {
+        this.salePrice = salePrice;
+    }
+
+    public double computeDropRate()
+    {
+        return 0.0;//NON TERMINER        
+    }
+
+    public double getMileageDropRate() {
+        return mileageDropRate;
+    }
+
+    public double getTemporalDropRate() {
+        return temporalDropRate;
+    }
+}
\ No newline at end of file
diff --git a/src/tp06/Company.java b/src/tp06/Company.java
new file mode 100644
index 0000000..3a40201
--- /dev/null
+++ b/src/tp06/Company.java
@@ -0,0 +1,81 @@
+package tp06;
+
+import java.time.LocalDate;
+import java.util.ArrayList;
+
+public class Company
+{
+    public static final ArrayList<Employee> EMPLOYEES = new ArrayList<>();
+    
+    public void addEmployee(Employee e)
+    {
+        EMPLOYEES.add(e);
+    }
+
+    public void supprEmployee(int i)
+    {
+        EMPLOYEES.remove(i);
+    }
+
+    public void supprEmployee(Employee e)
+    {
+        EMPLOYEES.remove(e);
+    }
+
+    public int getNbEmployee()
+    {
+        return EMPLOYEES.size();
+    }
+
+    private int getNumbClass(Class c)
+    {
+        int nb = 0;
+
+        for(int i = 0;i<=EMPLOYEES.size();i++)
+        {
+            if(EMPLOYEES.get(i).getClass() == c)
+            {
+                nb=nb+1;
+            }
+        }
+        return nb;
+    }
+
+    public int getNbSalesPerson()
+    {
+        return getNumbClass(Salesperson.class);
+    }
+
+    public int getNbWorker()
+    {
+        return getNumbClass(Worker.class);
+    }
+
+    public void firing(LocalDate fatefulDate)
+    {
+        for(int i = 0;i<=EMPLOYEES.size();i++)
+        {
+            if(EMPLOYEES.get(i).getHiringDate().toString().equals(fatefulDate.toString()))
+            {
+                EMPLOYEES.remove(i);
+            }
+        }
+    }
+
+    public void firing()
+    {
+        for(int i = 0;i<=EMPLOYEES.size();i++)
+        {
+            if(EMPLOYEES.get(i).objectiveFulfilled())
+            {
+                EMPLOYEES.remove(i);
+            }
+        }
+    }
+
+    @Override
+    public String toString()
+    {
+        return "Class Company.java";
+    }
+}
\ No newline at end of file
diff --git a/src/tp06/Employee.java b/src/tp06/Employee.java
new file mode 100644
index 0000000..c8c8b64
--- /dev/null
+++ b/src/tp06/Employee.java
@@ -0,0 +1,37 @@
+package tp06;
+
+import java.time.LocalDate;
+
+public abstract class Employee
+{
+    private String name;
+    private LocalDate hiringDate;
+
+    public Employee(String n, LocalDate ld)
+    {
+        this.name=n;
+        this.hiringDate=ld;
+    }
+
+    public String getName()
+    {
+        return this.name;
+    }
+
+    public LocalDate getHiringDate()
+    {
+        return hiringDate;
+    }
+
+    @Override
+    public String toString()
+    {
+        return getTitle() + " " + getName();
+    }
+
+    public abstract boolean objectiveFulfilled();
+
+    public abstract String getTitle();
+
+    public abstract double getWages();
+}
\ No newline at end of file
diff --git a/src/tp06/Salesperson.java b/src/tp06/Salesperson.java
new file mode 100644
index 0000000..02535cb
--- /dev/null
+++ b/src/tp06/Salesperson.java
@@ -0,0 +1,35 @@
+package tp06;
+
+import java.time.LocalDate;
+
+public abstract class Salesperson extends Employee
+{
+    private double turnover;
+    private static double objective = 10000.0;
+
+    public Salesperson(String n, LocalDate ld, double t)
+    {
+        super(n, ld);
+        this.turnover=t;
+    }
+
+    public double getTurnover()
+    {
+        return turnover;
+    }
+
+    public boolean objectiveFulfilled()
+    {
+        if(turnover>=objective)
+        {
+            return true;
+        }
+        return false;
+    }
+
+    @Override
+    public String toString()
+    {
+        return super.toString();
+    }
+}
diff --git a/src/tp06/TravellingSalesperson.java b/src/tp06/TravellingSalesperson.java
new file mode 100644
index 0000000..e3dc0fe
--- /dev/null
+++ b/src/tp06/TravellingSalesperson.java
@@ -0,0 +1,26 @@
+package tp06;
+
+import java.time.LocalDate;
+
+public class TravellingSalesperson extends Salesperson
+{
+    private static final double POURCENTAGE = 1.20;
+    private static final int BONUS = 800;
+
+    public TravellingSalesperson(String n, LocalDate ld, double t)
+    {
+        super(n, ld, t);
+    }
+
+    @Override
+    public String getTitle()
+    {
+        return "TravellingSalesperson";
+    }
+
+    @Override
+    public double getWages()
+    {
+        return getWages()+800;
+    }
+}
\ No newline at end of file
diff --git a/src/tp06/Vendor.java b/src/tp06/Vendor.java
new file mode 100644
index 0000000..2652c2e
--- /dev/null
+++ b/src/tp06/Vendor.java
@@ -0,0 +1,26 @@
+package tp06;
+
+import java.time.LocalDate;
+
+public class Vendor extends Salesperson
+{
+    private static final double POURCENTAGE = 1.20;
+    private static final int BONUS = 400;
+
+    public Vendor(String n, LocalDate ld, double t)
+    {
+        super(n, ld, t);
+    }
+
+    @Override
+    public String getTitle()
+    {
+        return getName();
+    }
+
+    @Override
+    public double getWages()
+    {
+        return getWages()+400;
+    }
+}
diff --git a/src/tp06/Worker.java b/src/tp06/Worker.java
new file mode 100644
index 0000000..6bed32b
--- /dev/null
+++ b/src/tp06/Worker.java
@@ -0,0 +1,43 @@
+package tp06;
+
+import java.time.LocalDate;
+
+public class Worker extends Employee
+{
+    private static final double BY_UNIT = 5.0;
+    private int units;
+    private static int objective = 10000;
+
+    public Worker(String n, LocalDate ld, int u)
+    {
+        super(n, ld);
+        this.units=u;
+    }
+
+    @Override
+    public String getTitle()
+    {
+        return "Worker";
+    }
+
+    public boolean objectiveFulfilled()
+    {
+        if(units>=objective)
+        {
+            return true;
+        }
+        return false;
+    }
+
+    @Override
+    public double getWages()
+    {
+        return BY_UNIT*units;
+    }
+    
+    @Override
+    public String toString()
+    {
+        return getTitle() + " " + getName();
+    }
+}
\ No newline at end of file
-- 
GitLab