From: Jérôme Benoit Date: Fri, 6 Apr 2018 08:12:14 +0000 (+0200) Subject: exo4: print classes created after the year 2009. X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=3b1969267fdc47fa2abbd459d3ab1306b294bdb3;p=Project_POO.git exo4: print classes created after the year 2009. Signed-off-by: Jérôme Benoit --- diff --git a/exo2/ListExtension.java b/exo2/ListExtension.java index d7eae5b..20e9fb2 100644 --- a/exo2/ListExtension.java +++ b/exo2/ListExtension.java @@ -37,7 +37,7 @@ public class ListExtension { } /** - * Should mimic the List add(int index, T value) method + * Should mimic the List add(int index, E value) method * @param index [description] * @param value [description] * @return [description] diff --git a/exo4/Main.java b/exo4/Main.java index 7c17dd8..48b9391 100644 --- a/exo4/Main.java +++ b/exo4/Main.java @@ -1,5 +1,8 @@ import java.util.LinkedList; import java.lang.annotation.Annotation; +import java.util.Date; +import java.text.SimpleDateFormat; +import java.text.ParseException; class Main { @@ -10,6 +13,7 @@ class Main { public static void main(String[] args) { //FIXME: one can create a smart way of building this list LinkedList> packageClasses = new LinkedList>(); + packageClasses.add(Cercle.class); packageClasses.add(Entiers.class); packageClasses.add(Forme.class); packageClasses.add(Image.class); @@ -19,13 +23,24 @@ class Main { packageClasses.add(Segment.class); packageClasses.add(Structure.class); + System.out.println("Class list created after 2009:"); for (Class cl : packageClasses) { ClassPreamble classPreamble = cl.getAnnotation(ClassPreamble.class); if (classPreamble == null) { System.out.println("No annotation for " + cl.getName()); continue; } - System.out.println(cl.getName() + " class annotation date = " + classPreamble.date()); + try { + SimpleDateFormat sdf = new SimpleDateFormat("dd/M/yyyy"); + Date date = sdf.parse(classPreamble.date()); + Integer classYear = date.getYear() + 1900; + if (classYear >= 2009) { + System.out.println(" " + cl.getName() + " created year " + classYear + "."); + } + } + catch (ParseException e) { + + } } } } diff --git a/exo4/Piletransformations.java b/exo4/Piletransformations.java index 2d7874c..01bab7e 100644 --- a/exo4/Piletransformations.java +++ b/exo4/Piletransformations.java @@ -1,7 +1,7 @@ @ClassPreamble ( author = "Jérôme Benoit", - date = "06/21/2009" + date = "06/21/2002" ) class Piletransformations { private Point[] transformations;