Skip to content
Open
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
57 changes: 57 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,57 @@
package com.ipiecoles.java.java220;

import org.joda.time.LocalDate;

import java.util.Objects;

public class Cadre extends Employe {

private Double coefficient = 1.0;

public Cadre() {

}

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

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ajoute un constructeur qui instancie ton attribut coefficient


public Double getCoefficient() {
return coefficient;
}

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

public Double getPrimeAnnuelle() {

return Entreprise.primeAnnuelleBase() * coefficient;
}

public Integer getNbConges() {
return super.getNbConges() + (int)Math.ceil(this.coefficient);
}

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

public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Cadre)) return false;
if (!super.equals(o)) return false;

Cadre cadre = (Cadre) o;
return coefficient != null ? coefficient.equals(cadre.coefficient) : cadre.coefficient == null;
}

@Override
public String toString() {
return "Cadre{" +
"coefficient=" + coefficient +
"} " + super.toString();
}
}
37 changes: 36 additions & 1 deletion src/main/java/com/ipiecoles/java/java220/Employe.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ public abstract class Employe {
private LocalDate dateEmbauche;

private Double salaire = Entreprise.SALAIRE_BASE;

private Boolean tempsPartiel;

private String sexe;

public Employe() {

Expand All @@ -29,6 +33,33 @@ public Employe(String nom, String prenom, String matricule, LocalDate dateEmbauc
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 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() - dateEmbauche.getYear();
}
Expand Down Expand Up @@ -125,6 +156,8 @@ public String toString() {
sb.append(", matricule='").append(matricule).append('\'');
sb.append(", dateEmbauche=").append(dateEmbauche);
sb.append(", salaire=").append(salaire);
sb.append(", tempsPartiel=").append(tempsPartiel);
sb.append(", sexe=").append(sexe);
sb.append('}');
return sb.toString();
}
Expand All @@ -140,12 +173,14 @@ public boolean equals(Object o) {
if (nom != null ? !nom.equals(employe.nom) : employe.nom != null) return false;
if (prenom != null ? !prenom.equals(employe.prenom) : employe.prenom != null) return false;
if (matricule != null ? !matricule.equals(employe.matricule) : employe.matricule != null) return false;
if (sexe != null ? !sexe.equals(employe.sexe) : employe.sexe != null) return false;
if (tempsPartiel != null ? !tempsPartiel.equals(employe.tempsPartiel) : employe.tempsPartiel != null) return false;
return dateEmbauche != null ? dateEmbauche.equals(employe.dateEmbauche) : employe.dateEmbauche == null;

}

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