Skip to content
Snippets Groups Projects
Commit eefa2917 authored by Samuel Turpin's avatar Samuel Turpin :computer:
Browse files

tp6 presque fini

parent c97c853f
No related branches found
No related tags found
No related merge requests found
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
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
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
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();
}
}
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
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;
}
}
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment