Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dev-oo
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Samuel Turpin
dev-oo
Commits
e8465adc
Commit
e8465adc
authored
1 year ago
by
samuel turpin
Browse files
Options
Downloads
Patches
Plain Diff
presque fini tp3 ex2
parent
fa60704a
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
.gitignore
+1
-1
1 addition, 1 deletion
.gitignore
src/tp01/HighScore.java
+1
-1
1 addition, 1 deletion
src/tp01/HighScore.java
src/tp03/UseLocalDate.class
+0
-0
0 additions, 0 deletions
src/tp03/UseLocalDate.class
src/tp03/UseLocalDate.java
+89
-0
89 additions, 0 deletions
src/tp03/UseLocalDate.java
with
91 additions
and
2 deletions
.gitignore
+
1
−
1
View file @
e8465adc
bin/
*/*.class
*/*.lib
\ No newline at end of file
*/*.jar
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/tp01/HighScore.java
+
1
−
1
View file @
e8465adc
...
...
@@ -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
)
{
...
...
This diff is collapsed.
Click to expand it.
src/tp03/UseLocalDate.class
0 → 100644
+
0
−
0
View file @
e8465adc
File added
This diff is collapsed.
Click to expand it.
src/tp03/UseLocalDate.java
0 → 100644
+
89
−
0
View file @
e8465adc
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
());
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment