2019_2020:s2:etudefilrouge:verslecode
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
2019_2020:s2:etudefilrouge:verslecode [2020/02/16 15:26] – created blay | 2019_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:// | + | **Reprenez le diagramme de classes et pour les classes qui sont utilisées dans le [[https:// |
+ | 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' | ||
+ | Birthday aBirthday = new Birthday(LocalDate.of(2000, | ||
+ | Birthday bBirthday = new Birthday(LocalDate.of(2000, | ||
+ | Birthday herculeBirthday = new Birthday(LocalDate.of(2000, | ||
+ | Birthday geekBirthday = new Birthday(LocalDate.of(2000, | ||
+ | Birthday dDBirthday = new Birthday(LocalDate.of(2000, | ||
+ | Birthday yvetteBirthday = new Birthday(LocalDate.of(2000, | ||
+ | List< | ||
+ | new ArrayList<> | ||
+ | birthdayList.removeIf( (b -> ( (b.numberOfDaysAfterToday()< | ||
+ | | ||
+ | |||
+ | System.out.println(birthdayList); | ||
+ | |||
+ | |||
+ | //// | ||
+ | //Elle écrit : “Bon anniversaire ! “ | ||
+ | Message message = new Message(geekBirthday, | ||
+ | System.out.println(message); | ||
+ | System.out.println(geekBirthday); | ||
+ | |||
+ | |||
+ | } | ||
+ | </ | ||
+ | |||
+ | |||
+ | 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(), | ||
+ | return (int) ChronoUnit.DAYS.between(now, | ||
+ | } | ||
+ | </ |
2019_2020/s2/etudefilrouge/verslecode.1581866815.txt.gz · Last modified: 2020/02/16 15:26 by blay