User Tools

Site Tools


2019_2020:s2:etudefilrouge:verslecode

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
2019_2020:s2:etudefilrouge:verslecode [2020/02/16 15:26] – created blay2019_2020:s2:etudefilrouge:verslecode [2020/02/16 16:55] (current) blay
Line 2: Line 2:
  
  
-Reprenez le diagramme de classes et pour les classes qui sont utilisées dans le [[https://mbf-iut.i3s.unice.fr/doku.php?id=2019_2020:s2:etudefilrouge:bilanintermediaire#un_exemple_test_pour_verifier_que_tout_y_est|test]], générer et complétez l'implémentation.+**Reprenez le diagramme de classes et pour les classes qui sont utilisées dans le [[https://mbf-iut.i3s.unice.fr/doku.php?id=2019_2020:s2:etudefilrouge:bilanintermediaire#un_exemple_test_pour_verifier_que_tout_y_est|test]], générer et complétez l'implémentation.**
  
  
 +Voici un exemple de tests que vous pouvez faire : 
 +
 +<code java>
 +public class TestValidation {
 +
 + public static void main(String[] args) {
 + //(il y en a 4, ordonnés dans l'ordre chronologique des anniversaires : Hercule, Geek00, D.D., Yvette), celui de Hercule.
 + Birthday aBirthday = new Birthday(LocalDate.of(2000, 02, 12),"a'");
 + Birthday bBirthday = new Birthday(LocalDate.of(2000, 04, 12),"b'");
 + Birthday herculeBirthday = new Birthday(LocalDate.of(2000, 02, 18),"Hercule'");
 + Birthday geekBirthday = new Birthday(LocalDate.of(2000, 02, 19),"Geek00'");
 + Birthday dDBirthday = new Birthday(LocalDate.of(2000, 02, 20),"D.D'");
 + Birthday yvetteBirthday = new Birthday(LocalDate.of(2000, 03, 1),"Yvette'");
 + List<Birthday> birthdayList = 
 + new ArrayList<>(Arrays.asList(herculeBirthday, geekBirthday,dDBirthday,yvetteBirthday, aBirthday, bBirthday));
 + birthdayList.removeIf( (b -> ( (b.numberOfDaysAfterToday()<0) || 
 +                (b.numberOfDaysAfterToday()>15) ) ) )  ;
 +
 + System.out.println(birthdayList);
 +
 +
 + ////Pénélope sélectionne parmi les anniversaires qui lui sont proposés pour les 15 jours à venir 
 + //Elle écrit : “Bon anniversaire ! “
 + Message message = new Message(geekBirthday, "Bon anniversaire");
 + System.out.println(message);
 + System.out.println(geekBirthday);
 +
 +
 + }
 +</code>
 +
 +
 +et pour comparer des dates si besoin (Attention, ce n'est pas la classe Birthday compléte, juste quelques éléments pour vous aider) : 
 +<code java>
 +import java.time.LocalDate;
 +import java.time.temporal.ChronoUnit;
 +
 +public class Birthday {
 + private LocalDate aDate;
 + private String aName;
 +
 + public Birthday(LocalDate pDate, String pName) {
 + aDate = pDate;
 + aName = pName;
 + }
 +
 + public int numberOfDaysAfterToday() {
 + LocalDate now = LocalDate.now();
 + LocalDate thisYearDate = LocalDate.of(now.getYear(), aDate.getMonth(), aDate.getDayOfMonth());
 + return (int) ChronoUnit.DAYS.between(now, thisYearDate);
 + }
 +</code>
2019_2020/s2/etudefilrouge/verslecode.1581866815.txt.gz · Last modified: 2020/02/16 15:26 by blay