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

Both sides previous revision Previous revision
Next revision
Previous revision
2019_2020:s2:etudefilrouge:verslecode [2020/02/16 17:27]
blay
2019_2020:s2:etudefilrouge:verslecode [2020/02/16 17:55]
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.**
  
  
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'​ordre chronologique des anniversaires : Hercule, Geek00, D.D., Yvette), celui de Hercule.  //(il y en a 4, ordonnés dans l'​ordre chronologique des anniversaires : Hercule, Geek00, D.D., Yvette), celui de Hercule.
- Birthday herculeBirthday = new Birthday(LocalDate.of(2000,​ 02, 20),"​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 geekBirthday = new Birthday(LocalDate.of(2000,​ 02, 19),"​Geek00'"​);​
- Birthday dDBirthday = new Birthday(LocalDate.of(2000,​ 02, 18),"​D.D'"​);​ + Birthday dDBirthday = new Birthday(LocalDate.of(2000,​ 02, 20),"​D.D'"​);​ 
- Birthday yvetteBirthday = new Birthday(LocalDate.of(2000, ​0221),"​Yvette'"​);​+ Birthday yvetteBirthday = new Birthday(LocalDate.of(2000, ​031),"​Yvette'"​);​
  List<​Birthday>​ birthdayList =   List<​Birthday>​ birthdayList = 
- new ArrayList<>​(Arrays.asList(herculeBirthday,​ geekBirthday,​dDBirthday,​yvetteBirthday )); + new ArrayList<>​(Arrays.asList(herculeBirthday,​ geekBirthday,​dDBirthday,​yvetteBirthday, aBirthday, bBirthday)); 
- birthdayList.sort(Comparator.comparingInt(Birthday::numberOfDaysAfterToday));​+ birthdayList.removeIf(b -> ( (b.numberOfDaysAfterToday()<0) ||  
 +                (b.numberOfDaysAfterToday()>15) ) )  ​; 
 +
  System.out.println(birthdayList);​  System.out.println(birthdayList);​
 +
   
  ////​Pénélope sélectionne parmi les anniversaires qui lui sont proposés pour les 15 jours à venir   ////​Pénélope sélectionne parmi les anniversaires qui lui sont proposés pour les 15 jours à venir 
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 ​(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.txt · Last modified: 2020/02/16 17:55 by blay