2019_2020:s2:etudefilrouge:verslecode
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
2019_2020:s2:etudefilrouge:verslecode [2020/02/16 16:27] – 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:// |
Line 12: | Line 12: | ||
public static void main(String[] args) { | public static void main(String[] args) { | ||
//(il y en a 4, ordonnés dans l' | //(il y en a 4, ordonnés dans l' | ||
- | Birthday herculeBirthday = new Birthday(LocalDate.of(2000, | + | 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 geekBirthday = new Birthday(LocalDate.of(2000, | ||
- | Birthday dDBirthday = new Birthday(LocalDate.of(2000, | + | Birthday dDBirthday = new Birthday(LocalDate.of(2000, |
- | Birthday yvetteBirthday = new Birthday(LocalDate.of(2000, | + | Birthday yvetteBirthday = new Birthday(LocalDate.of(2000, |
List< | List< | ||
- | new ArrayList<> | + | new ArrayList<> |
- | birthdayList.sort(Comparator.comparingInt(Birthday::numberOfDaysAfterToday)); | + | birthdayList.removeIf( (b -> ( (b.numberOfDaysAfterToday()<0) || |
+ | (b.numberOfDaysAfterToday()>15) ) ) ) | ||
+ | |||
System.out.println(birthdayList); | System.out.println(birthdayList); | ||
+ | |||
//// | //// | ||
Line 26: | Line 31: | ||
System.out.println(message); | System.out.println(message); | ||
System.out.println(geekBirthday); | System.out.println(geekBirthday); | ||
+ | |||
} | } | ||
Line 31: | Line 37: | ||
- | et Pour comparer des dates si besoin : | + | et pour comparer des dates si besoin |
+ | <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.1581870454.txt.gz · Last modified: 2020/02/16 16:27 by blay