Guest User

Untitled

a guest
Dec 13th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.42 KB | None | 0 0
  1. /**
  2. *
  3. */
  4. package iut.acy.cut4u.model;
  5.  
  6. import java.util.ArrayList;
  7. import java.util.GregorianCalendar;
  8.  
  9.  
  10. /**
  11. * @author cazajeug
  12. *
  13. */
  14. /**
  15. * @author cazajeug
  16. *
  17. */
  18. public class Employe extends Personne {
  19.  
  20. private StatutEmploye statut;
  21. private CategorieEmploye categorie;
  22. private ArrayList<Conge> conges;
  23. private ArrayList<Integer> demiJoursRepos;
  24.  
  25. public boolean estEnRepos(int demiJour) throws IllegalArgumentException {
  26. // TO DO
  27. // le paramètre passé doit être compris entre 1 et 14
  28. // veuillez vous assurer d'avoir le tag nécessaire pour que l'exception
  29. // soit
  30. // mentionnée au sein de la javadoc
  31. if (demiJour > 14 || demiJour < 0) {
  32. throw new IllegalArgumentException(
  33. "Impossible que ce soit inférieur à 0 ou supérieur à 14");
  34. }
  35. return (this.demiJoursRepos.contains(demiJour));
  36.  
  37. }
  38.  
  39. public boolean estEnConge(GregorianCalendar jour) {
  40. if (jour == null)
  41. throw new IllegalArgumentException("Allo, le jour n'existe pas !");
  42. for (Conge c : conges) {
  43. if (c.getDateDebut().compareTo(jour) <= 0
  44. && jour.compareTo(c.getDateFin()) <= 0)
  45. return true;
  46. }
  47. return false;
  48.  
  49. }
  50.  
  51.  
  52. /**
  53. * @param id
  54. * @param sexe
  55. * @param nom
  56. * @param prenom
  57. * @param statut
  58. * @param categorie
  59. * @param adresse
  60. * @param codePostal
  61. * @param ville
  62. * @param tel
  63. * @param conges
  64. * @param demiJoursRepos
  65. */
  66. public Employe(int id, Sexe sexe, String nom, String prenom,
  67. StatutEmploye statut, CategorieEmploye categorie, String adresse,
  68. String codePostal, String ville, String tel,
  69. ArrayList<Conge> conges, ArrayList<Integer> demiJoursRepos) {
  70. super(id, sexe, nom, prenom, adresse, codePostal, ville, tel);
  71. this.setStatut(statut);
  72. this.setCategorie(categorie);
  73. this.setConges(conges);
  74. this.setDemiJoursRepos(demiJoursRepos);
  75.  
  76. }
  77.  
  78.  
  79. /**
  80. * @param sexe
  81. * @param nom
  82. * @param prenom
  83. * @param statut
  84. * @param categorie
  85. */
  86. public Employe(Sexe sexe, String nom, String prenom, StatutEmploye statut,
  87. CategorieEmploye categorie) {
  88. this(0, sexe, nom, prenom, statut, categorie, "", "", "", "",
  89. new ArrayList<Conge>(), new ArrayList<Integer>());
  90. }
  91.  
  92.  
  93. /**
  94. * @return
  95. */
  96.  
  97. public ArrayList<Integer> getDemiJoursRepos() {
  98. return demiJoursRepos;
  99. }
  100.  
  101.  
  102. /**
  103. * @param joursRepos
  104. */
  105. public void setDemiJoursRepos(ArrayList<Integer> joursRepos) {
  106. if (joursRepos != null)
  107. this.demiJoursRepos = joursRepos;
  108. else
  109. this.demiJoursRepos = new ArrayList<Integer>();
  110. }
  111.  
  112. /**
  113. * ajoute le congé passé en paramètre
  114. *
  115. * @return true si l'ajout s'est bien effectué sinon false
  116. */
  117.  
  118. public boolean ajouteConge(Conge c) {
  119. if (this.conges.add(c))
  120. return true;
  121. else
  122. return false;
  123. }
  124.  
  125. /**
  126. * ajoute le demi-jour de repos passé en paramètre
  127. *
  128. * @return true si l'ajout s'est bien effectué sinon false
  129. */
  130. public boolean ajouteDemiJourRepos(int demiJournee) {
  131.  
  132. if (this.demiJoursRepos.contains(demiJournee))
  133. return false;
  134. this.demiJoursRepos.add(demiJournee);
  135. return true;
  136. }
  137.  
  138. /**
  139. * @param args
  140. */
  141. public static void main(String[] args) {
  142.  
  143. }
  144.  
  145. /**
  146. * renvoie le statut de l'employé
  147. *
  148. * @return the statut
  149. */
  150. public StatutEmploye getStatut() {
  151. return statut;
  152. }
  153.  
  154. /**
  155. * met à jour le statut de l'employé
  156. *
  157. * @param statut
  158. * the statut to set
  159. */
  160. public void setStatut(StatutEmploye statut) {
  161. this.statut = statut;
  162. }
  163.  
  164. /**
  165. * @return the categorie
  166. */
  167. public CategorieEmploye getCategorie() {
  168. return categorie;
  169. }
  170.  
  171. /**
  172. * @param categorie
  173. * the categorie to set
  174. */
  175. public void setCategorie(CategorieEmploye categorie) {
  176. this.categorie = categorie;
  177. }
  178.  
  179. /**
  180. * @return the conges
  181. */
  182. public ArrayList<Conge> getConges() {
  183. return conges;
  184. }
  185.  
  186. /**
  187. * @param conges
  188. * the conges to set
  189. */
  190. public void setConges(ArrayList<Conge> conges) {
  191. if (conges != null)
  192. this.conges = conges;
  193. else
  194. this.conges = new ArrayList<Conge>();
  195. }
  196.  
  197. }
Add Comment
Please, Sign In to add comment