Skip to content
Open

Eval #18

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
61 changes: 61 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,61 @@
package com.ipiecoles.java.java220;


import org.joda.time.LocalDate;

import java.util.Objects;

public class Cadre extends Employe{

private Double coefficient = 1d;

public Double getCoefficient() {
return coefficient;
}

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

public Cadre(){}

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;
}

@Override
public String toString() {
return "Cadre{" +
"coefficient=" + coefficient +
"} " + super.toString();
}

@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 Double getPrimeAnnuelle() {
return this.getPrimeAnnuelle() * this.coefficient;
}

@Override
public Integer getNbConges() {
return (int) (Math.ceil(this.coefficient)+Entreprise.NB_CONGES_BASE);
}
}
80 changes: 80 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,80 @@
package com.ipiecoles.java.java220;

import org.joda.time.LocalDate;

import java.util.Objects;

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

public Commercial() { }

public Commercial(Double caAnnuel) {
this.caAnnuel = caAnnuel;
}

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

public Double getCaAnnuel() {
return caAnnuel;
}

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

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

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

@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);
}

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

public Boolean performanceEgale(Integer perfDemande ){
return this.performance.equals(perfDemande);
}

public Note equivalenceNote(){

switch (performance){
case 0:

case 50:
return Note.INSUFISSANT;

case 100:
return Note.PASSABLE;

case 150:
return Note.BIEN;

case 200:
return Note.TRES_BIEN;

default:
return null;
}
}
}
124 changes: 123 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,129 @@
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, 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 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 LocalDate getDateEmbauche() {
return dateEmbauche;
}

public void setDateEmbauche(LocalDate dateEmbauche) throws Exception{
if(dateEmbauche != null && 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 this.salaire;
}

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 final Integer getNombreAnneeAnciennete(){
return LocalDate.now().getYear() - this.dateEmbauche.getYear();
}

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

@Override
public String toString() {
return "Employe{" +
"nom='" + nom + '\'' +
", prenom='" + prenom + '\'' +
", matricule='" + matricule + '\'' +
", dateEmbauche=" + dateEmbauche +
", salaire=" + salaire +
", tempsPartiel=" + tempsPartiel +
", sexe='" + sexe + '\'' +
'}';
}

@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);
}

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

public abstract Double getPrimeAnnuelle();
}
17 changes: 17 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,17 @@
package com.ipiecoles.java.java220;
import org.joda.time.LocalDate;

import javax.swing.*;


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 = 100.0;

public static Double primeAnnuelleBase(){
return LocalDate.now().getYear() / 2.0;
}
}
58 changes: 58 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,58 @@
package com.ipiecoles.java.java220;

import com.ipiecoles.java.java220.exceptions.TechnicienException;
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, Boolean tempsPartiel, String sexe, HashSet<Technicien> equipe) {
super(nom, prenom, matricule, dateEmbauche, salaire, tempsPartiel, sexe);
this.equipe = equipe;
}

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


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

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

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

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

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

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

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

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

public enum Note { INSUFISSANT, PASSABLE, BIEN, TRES_BIEN}
Loading