diff --git a/src/tp06/Car.java b/src/tp06/Car.java new file mode 100644 index 0000000000000000000000000000000000000000..ba2e51609035be6ff54a84f7d3698d6cbe36d943 --- /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 0000000000000000000000000000000000000000..3a402018a9b51aee5ed4794284341fbef3f2b576 --- /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 0000000000000000000000000000000000000000..c8c8b64354121c183d3cae22fcc7ef02c271730d --- /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 0000000000000000000000000000000000000000..02535cb1ae7171156534f0e3e12886a8d204db81 --- /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 0000000000000000000000000000000000000000..e3dc0fe6829bdc55295d747c46767a3e5dc780a3 --- /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 0000000000000000000000000000000000000000..2652c2e28fd43411ddaf11d31506bcbf1dcbdff5 --- /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 0000000000000000000000000000000000000000..6bed32b4f3698db495b8e6a028e80a576c064955 --- /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