Skip to content
Open

Eval #16

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>16</source>
<target>16</target>
<source>15</source>
<target>15</target>
</configuration>
</plugin>
</plugins>
Expand Down
63 changes: 63 additions & 0 deletions src/main/java/com/ipiecoles/java/java220/Cadre.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package com.ipiecoles.java.java220;

import org.joda.time.LocalDate;

import java.util.Objects;

public class Cadre extends Employe{

private Double coefficient = 1d;

public Cadre(Double coefficient) {
this.coefficient = coefficient;
}

public Cadre(String nom, String prenom, String matricule, LocalDate dateEmbauche, Double salaire, Double coefficient) {
super(nom, prenom, matricule, dateEmbauche, salaire);
this.coefficient = coefficient;
}

public Cadre(String nom, String prenom, String matricule, LocalDate dateEmbauche, Double salaire, Boolean tempsPartiel, String sexe, Double coefficient) {
super(nom, prenom, matricule, dateEmbauche, salaire, tempsPartiel, sexe);
this.coefficient = coefficient;
}

public Double getCoefficient() {
return coefficient;
}

public void setCoefficient(Double coefficient) {
this.coefficient = coefficient;
}

@Override
public Double getPrimeAnnuelle() {
return Entreprise.primeAnnuelleBase() * this.coefficient;
}

@Override
public Integer getNbConges(){
return Entreprise.NB_CONGES_BASE+ (int) Math.round(this.coefficient);
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
Cadre cadre = (Cadre) o;
return Objects.equals(coefficient, cadre.coefficient);
}

@Override
public int hashCode() {
return Objects.hash(super.hashCode(), coefficient);
}

@Override
public String toString() {
return "Cadre{" +
"coefficient=" + coefficient +
'}';
}
}
79 changes: 79 additions & 0 deletions src/main/java/com/ipiecoles/java/java220/Commercial.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package com.ipiecoles.java.java220;

import org.joda.time.LocalDate;

import java.util.Objects;

public class Commercial extends Employe{
private Double caAnnuel;
private Integer performance;

public Commercial(){

}

public Commercial(String nom, String prenom, String matricule,
LocalDate dateEmbauche, Double salaire, Double caAnnuel) {
super(nom, prenom, matricule, dateEmbauche, salaire);
this.caAnnuel = caAnnuel;
}

public Commercial(String nom, String prenom, String matricule, LocalDate dateEmbauche, Double salaire, Double caAnnuel, Integer performance) {
this(nom, prenom, matricule, dateEmbauche, salaire, caAnnuel);
this.performance = performance;
}

@Override
public Double getPrimeAnnuelle() {
if (this.caAnnuel == null){
return 500d;
}
return Math.max(Math.ceil(this.getCaAnnuel() * 0.05), 500d);
}

public boolean performanceEgale(Integer performance){
if (this.performance.equals(performance)){
return true;
}
else
return false;
}

public Double getCaAnnuel() {
return caAnnuel;
}

public void setCaAnnuel(Double caAnnuel) {
this.caAnnuel = caAnnuel;
}

public Integer getPerformance() {
return performance;
}

public void setPerformance(Integer performance) {
this.performance = performance;
}

@Override
public String toString() {
return "Commercial{" +
"caAnnuel=" + caAnnuel +
", performance=" + performance +
'}';
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
Commercial that = (Commercial) o;
return Objects.equals(caAnnuel, that.caAnnuel) && Objects.equals(performance, that.performance);
}

@Override
public int hashCode() {
return Objects.hash(super.hashCode(), caAnnuel, performance);
}
}
134 changes: 133 additions & 1 deletion src/main/java/com/ipiecoles/java/java220/Employe.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,139 @@
package com.ipiecoles.java.java220;

import org.joda.time.LocalDate;

import java.util.Objects;

/**
* Created by pjvilloud on 21/09/17.
*/
public class Employe {
public abstract class Employe {
private String nom;
private String prenom;
private String matricule;
private LocalDate dateEmbauche;
private Double salaire;
private Boolean tempsPartiel;
private String sexe;

public Employe() {
}

public Employe(String nom, String prenom, String matricule,
LocalDate dateEmbauche, Double salaire) {
this.nom = nom;
this.prenom = prenom;
this.matricule = matricule;
this.dateEmbauche = dateEmbauche;
this.salaire = salaire;
}

public Employe(String nom, String prenom, String matricule, LocalDate dateEmbauche, Double salaire, Boolean tempsPartiel, String sexe) {
this.nom = nom;
this.prenom = prenom;
this.matricule = matricule;
this.dateEmbauche = dateEmbauche;
this.salaire = salaire;
this.tempsPartiel = tempsPartiel;
this.sexe = sexe;
}

public final Integer getNombreAnneeAnciennete (){
return LocalDate.now().getYear()- dateEmbauche.getYear();
}

public Integer getNbConges(){
return Entreprise.NB_CONGES_BASE;
}

public void augmenterSalaire(Double pourcentage){
this.salaire = this.getSalaire() * (1 + pourcentage);
}

public abstract Double getPrimeAnnuelle();

public String getNom() {
return nom;
}

public void setNom(String nom) {
this.nom = nom;
}

public String getPrenom() {
return prenom;
}

public void setPrenom(String prenom) {
this.prenom = prenom;
}

public String getMatricule() {
return matricule;
}

public void setMatricule(String matricule) {
this.matricule = matricule;
}

public void setSalaire(Double salaire) {
this.salaire = salaire;
}

public Boolean getTempsPartiel() {
return tempsPartiel;
}

public void setTempsPartiel(Boolean tempsPartiel) {
this.tempsPartiel = tempsPartiel;
}

public String getSexe() {
return sexe;
}

public void setSexe(String sexe) {
this.sexe = sexe;
}

public LocalDate getDateEmbauche() {
return dateEmbauche;
}

public void setDateEmbauche(LocalDate dateEmbauche) throws Exception {
if (dateEmbauche.isAfter(LocalDate.now())){
throw new Exception("La date d'embauche ne peut être postérieure à la date courante");
}
this.dateEmbauche = dateEmbauche;
}

public Double getSalaire() {
return salaire;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Employe employe = (Employe) o;
return Objects.equals(nom, employe.nom) && Objects.equals(prenom, employe.prenom) && Objects.equals(matricule, employe.matricule) && Objects.equals(dateEmbauche, employe.dateEmbauche) && Objects.equals(salaire, employe.salaire) && Objects.equals(tempsPartiel, employe.tempsPartiel) && Objects.equals(sexe, employe.sexe);
}

@Override
public int hashCode() {
return Objects.hash(nom, prenom, matricule, dateEmbauche, salaire, tempsPartiel, sexe);
}

@Override
public String toString() {
return "Employe{" +
"nom='" + nom + '\'' +
", prenom='" + prenom + '\'' +
", matricule='" + matricule + '\'' +
", dateEmbauche=" + dateEmbauche +
", salaire=" + salaire +
", tempsPartiel=" + tempsPartiel +
", sexe='" + sexe + '\'' +
'}';
}
}
15 changes: 15 additions & 0 deletions src/main/java/com/ipiecoles/java/java220/Entreprise.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.ipiecoles.java.java220;
import org.joda.time.LocalDate;

public class Entreprise {
public static final Double SALAIRE_BASE = 1480.27;
public static final Integer NB_CONGES_BASE = 25;
public static final Double INDICE_MANAGER = 1.3;
public static final Double PRIME_MANAGER_PAR_TECHNICIEN = 250.0;
public static final Double PRIME_ANCIENNETE = 100d;

public static Double primeAnnuelleBase(){
return LocalDate.now().getYear()/2d;
}

}
65 changes: 65 additions & 0 deletions src/main/java/com/ipiecoles/java/java220/Manager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package com.ipiecoles.java.java220;

import org.joda.time.LocalDate;

import java.util.HashSet;

public class Manager extends Employe{

private HashSet<Technicien> equipe = new HashSet();

public Manager(){

}

public Manager(String nom, String prenom, String matricule, LocalDate dateEmbauche, Double salaire, HashSet<Technicien> equipe) {
super(nom, prenom, matricule, dateEmbauche, salaire);
this.equipe = equipe;
}

@Override
public Double getPrimeAnnuelle() {
return Entreprise.primeAnnuelleBase() + equipe.size() * Entreprise.PRIME_MANAGER_PAR_TECHNICIEN;
}

public void ajoutTechnicienEquipe(Technicien technicien){
equipe.add(technicien);
}

public void ajoutTechnicienEquipe(String nom, String prenom, String matricule, LocalDate dateEmbauche, Double salaire, Integer grade) throws TechnicienException {
this.ajoutTechnicienEquipe(new Technicien(nom, prenom, matricule, dateEmbauche, salaire, grade));
}

@Override
public void setSalaire(Double salaire) {
super.setSalaire(salaire * Entreprise.INDICE_MANAGER + (salaire * equipe.size() / 10d));
}

public void augmenterSalaire(Double pourcentage) {
super.augmenterSalaire(pourcentage);
augmenterSalaireEquipe(pourcentage);
}

private void augmenterSalaireEquipe(Double pourcentage) {
for (Technicien technicien : equipe) {
technicien.augmenterSalaire(pourcentage);
}
}


public HashSet<Technicien> getEquipe() {
return equipe;
}

public void setEquipe(HashSet<Technicien> equipe) {
this.equipe = equipe;
}

private class TechnicienException extends Exception {
}

@Override
public String toString() {
return "Manager{} " + super.toString();
}
}
Loading