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
Changes from 1 commit
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
Next Next commit
add (*) -> added depart/arrive date for employe
withs committed Jan 6, 2023
commit 8daaf04b75f29b3fd7fcac5367c426d9c90de341
3 changes: 2 additions & 1 deletion Personnel/src/commandLine/LigueConsole.java
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@

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

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

import commandLineMenus.List;
@@ -99,7 +100,7 @@ private Option ajouterEmploye(final Ligue ligue)
{
ligue.addEmploye(getString("nom : "),
getString("prenom : "), getString("mail : "),
getString("password : "));
getString("password : "), LocalDate.now());
}
);
}
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
@@ -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;
}

/**
@@ -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.
@@ -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
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;

@@ -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();
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;
@@ -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;
}
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.*;
@@ -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", "g.bouchard@gmail.com", "azerty");
Employe employe = ligue.addEmploye("Bouchard", "Gérard", "g.bouchard@gmail.com", "azerty", LocalDate.now());
assertEquals(employe, ligue.getEmployes().first());
}
}