diff --git a/.gitignore b/.gitignore index 69e5d410002a047097bae484cdee42a635aa90d8..d7ac7438697e1c35822d770cb93978c34a7d995e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ bin/ */*.class -*/*.lib \ No newline at end of file +*/*.jar \ No newline at end of file diff --git a/src/tp01/HighScore.java b/src/tp01/HighScore.java index 84a91d36fe941b7d762978877ab68687905c7ae8..6f7873a4e3d366e60b04028445f4d911728cfb38 100644 --- a/src/tp01/HighScore.java +++ b/src/tp01/HighScore.java @@ -15,7 +15,7 @@ public class HighScore boolean ajout(Score newScore) { - for(int i = 0;i < top.length;i++) + for(int i = 0;i < top.length;) { if(top[i] != null) { diff --git a/src/tp03/UseLocalDate.class b/src/tp03/UseLocalDate.class new file mode 100644 index 0000000000000000000000000000000000000000..c9da901f9ce9c8337cf37adce6bc6c0bd99bab0d Binary files /dev/null and b/src/tp03/UseLocalDate.class differ diff --git a/src/tp03/UseLocalDate.java b/src/tp03/UseLocalDate.java new file mode 100644 index 0000000000000000000000000000000000000000..6e89bb08dd1c519e6ecbd1d15312908f9fcfc4ba --- /dev/null +++ b/src/tp03/UseLocalDate.java @@ -0,0 +1,89 @@ +package src.tp03; + +import java.time.Instant; +import java.time.LocalDate; +import java.time.ZoneId; +import util.Keyboard; + +public class UseLocalDate +{ + public static String dateOfTheDay() + { + String str = LocalDate.ofInstant(Instant.now(), ZoneId.systemDefault()).toString(); + return "Today’s date is " + str; + } + + private static boolean nombreValide(int nombre, int nbMin, int nbMax) + { + if (nombre >= nbMin && nombre <= nbMax) + { + return true; + } + return false; + } + + private static void whileB(int nbKey, int min, int max) + { + do + { + nbKey = Keyboard.readInt(); + }while(!(nombreValide(nbKey, min, max))); + } + + private static boolean bissextile(int year) + { + if(year % 4 == 0 && year >= 1582) + { + return true; + } + return false; + } + + public static LocalDate inputDate() + { + int year = 2004, month = 11, day = 3; + do + { + System.out.println("Entrez une année supérieur ou égal à 1970 :"); + year = Keyboard.readInt(); + }while(!(nombreValide(year, 1970, Integer.MAX_VALUE))); + + do + { + System.out.println("Entrez un mois entre 1 et 12 :"); + month = Keyboard.readInt(); + }while(!(nombreValide(month, 1, 12))); + + do + { + System.out.println("Entrez un jour entre 1 et 31 (doit être correct en fonction du mois ou de l'an bissextile) :"); + day = Keyboard.readInt(); + }while(!(nombreValide(day, 1, 31))); + /*whileB(year, 1970, Integer.MAX_VALUE); + whileB(month, 1, 12); + whileB(day, 1, 31);*/ + + if(day == 29 && month == 2 && !bissextile(year)) + { + System.out.println("Le 29 février " + year + " ! N'existe pas, veuillez entrer une année bissextile :"); + do{ + year = Keyboard.readInt(); + }while(!bissextile(year) && !(nombreValide(year, 1970, Integer.MAX_VALUE))); + } + LocalDate data = LocalDate.of(year, month, day); + if(data.getMonth().maxLength() == ) + { + + } + return data; + } + + public static void main(String[] args) + { + System.out.println(dateOfTheDay()); + LocalDate date = inputDate(); + System.out.println(date.getMonth()); + System.out.println(date.getMonth().maxLength()); + System.out.println(date.toString()); + } +}