Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arborescence #7

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
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
3 changes: 2 additions & 1 deletion Personnel/src/commandLine/LigueConsole.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static commandLineMenus.rendering.examples.util.InOut.getString;

import java.time.LocalDate;
import java.util.ArrayList;

import commandLineMenus.List;
Expand Down Expand Up @@ -99,7 +100,7 @@ private Option ajouterEmploye(final Ligue ligue)
{
ligue.addEmploye(getString("nom : "),
getString("prenom : "), getString("mail : "),
getString("password : "));
getString("password : "), LocalDate.now());
}
);
}
Expand Down
32 changes: 30 additions & 2 deletions Personnel/src/personnel/Employe.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package personnel;

import java.io.Serializable;
import java.time.LocalDate;

/**
* Employé d'une ligue hébergée par la M2L. Certains peuvent
Expand All @@ -14,17 +15,20 @@ public class Employe implements Serializable, Comparable<Employe>
{
private static final long serialVersionUID = 4795721718037994734L;
private String nom, prenom, password, mail;
private LocalDate date_arrive, date_depart;
private Ligue ligue;
private GestionPersonnel gestionPersonnel;

Employe(GestionPersonnel gestionPersonnel, Ligue ligue, String nom, String prenom, String mail, String password)
public Employe(GestionPersonnel gestionPersonnel, Ligue ligue, String nom, String prenom, String mail, String password, LocalDate arrive_en, LocalDate partit_en)
{
this.gestionPersonnel = gestionPersonnel;
this.nom = nom;
this.prenom = prenom;
this.password = password;
this.mail = mail;
this.ligue = ligue;
this.date_arrive = arrive_en;
this.date_depart = partit_en;
}

/**
Expand Down Expand Up @@ -144,6 +148,30 @@ public Ligue getLigue()
return ligue;
}

/* retourne la date d'arrive d'un employer
@return retourne la date d'arrive d'un employer */
public LocalDate getArrive() {
return this.date_arrive;
}

/* retourne la date de depart d'un employer
@return retourne la date de depart d'un employer */
public LocalDate getDepart() {
return this.date_depart;
}

/* affecte une nouvelle valeur a la date d'arrive
@param un objet LocalDate qui represente la nouvelle date d'arrive */
public void setArrive(LocalDate with_date) {
this.date_arrive = with_date;
}

/* affecte une nouvelle valeur a la date depart
@param un objet LocalDate qui represente la nouvelle date de depart */
public void setDepart(LocalDate with_date) {
this.date_depart = with_date;
}

/**
* Supprime l'employé. Si celui-ci est un administrateur, le root
* récupère les droits d'administration sur sa ligue.
Expand Down Expand Up @@ -174,7 +202,7 @@ public int compareTo(Employe autre)
@Override
public String toString()
{
String res = nom + " " + prenom + " " + mail + " (";
String res = nom + " " + prenom + " " + mail + " " + this.date_arrive + " (";
if (estRoot())
res += "super-utilisateur";
else
Expand Down
4 changes: 3 additions & 1 deletion Personnel/src/personnel/GestionPersonnel.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package personnel;

import java.io.Serializable;
import java.time.LocalDate;
import java.util.Collections;
import java.util.Optional;
import java.util.SortedSet;
import java.util.TreeSet;

Expand All @@ -20,7 +22,7 @@ public class GestionPersonnel implements Serializable
private static final long serialVersionUID = -105283113987886425L;
private static GestionPersonnel gestionPersonnel = null;
private SortedSet<Ligue> ligues;
private Employe root = new Employe(this, null, "root", "", "", "toor");
private Employe root = new Employe(this, null, "root", "", "", "toor", LocalDate.now(), LocalDate.now());
public final static int SERIALIZATION = 1, JDBC = 2,
TYPE_PASSERELLE = SERIALIZATION;
private static Passerelle passerelle = TYPE_PASSERELLE == JDBC ? new jdbc.JDBC() : new serialisation.Serialization();
Expand Down
5 changes: 3 additions & 2 deletions Personnel/src/personnel/Ligue.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package personnel;

import java.io.Serializable;
import java.time.LocalDate;
import java.util.Collections;
import java.util.SortedSet;
import java.util.TreeSet;
Expand Down Expand Up @@ -108,9 +109,9 @@ public SortedSet<Employe> getEmployes()
* @return l'employé créé.
*/

public Employe addEmploye(String nom, String prenom, String mail, String password)
public Employe addEmploye(String nom, String prenom, String mail, String password, LocalDate with_date)
{
Employe employe = new Employe(this.gestionPersonnel, this, nom, prenom, mail, password);
Employe employe = new Employe(this.gestionPersonnel, this, nom, prenom, mail, password, with_date, null);
employes.add(employe);
return employe;
}
Expand Down
Binary file not shown.
Binary file added Personnel/src/schema/arbre_heuris_PP.pdf
Binary file not shown.
25 changes: 25 additions & 0 deletions Personnel/src/testsUnitaires/testEmploye.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package testsUnitaires;

import java.time.LocalDate;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;

import personnel.*;

class testEmployer
{
GestionPersonnel gestionPersonnel = GestionPersonnel.getGestionPersonnel();

@Test
void test_date_arrive() throws SauvegardeImpossible {
LocalDate now = LocalDate.now();
Employe an_employer = new Employe(null, null, "bob", "", "", "toor", now, now);
assertEquals(an_employer.getArrive(), now);
}
@Test
void test_date_depart() throws SauvegardeImpossible {
LocalDate now = LocalDate.now();
Employe an_employer = new Employe(null, null, "bob", "", "", "toor", now, now);
assertEquals(an_employer.getDepart(), now);
}
}
5 changes: 4 additions & 1 deletion Personnel/src/testsUnitaires/testLigue.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package testsUnitaires;

import static org.junit.jupiter.api.Assertions.*;

import java.time.LocalDate;

import org.junit.jupiter.api.Test;

import personnel.*;
Expand All @@ -20,7 +23,7 @@ void createLigue() throws SauvegardeImpossible
void addEmploye() throws SauvegardeImpossible
{
Ligue ligue = gestionPersonnel.addLigue("Fléchettes");
Employe employe = ligue.addEmploye("Bouchard", "Gérard", "[email protected]", "azerty");
Employe employe = ligue.addEmploye("Bouchard", "Gérard", "[email protected]", "azerty", LocalDate.now());
assertEquals(employe, ligue.getEmployes().first());
}
}