Skip to content
Snippets Groups Projects
Commit e8465adc authored by samuel turpin's avatar samuel turpin
Browse files

presque fini tp3 ex2

parent fa60704a
No related branches found
No related tags found
No related merge requests found
bin/
*/*.class
*/*.lib
\ No newline at end of file
*/*.jar
\ No newline at end of file
......@@ -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)
{
......
File added
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());
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment