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
c97c853f
Commit
c97c853f
authored
1 year ago
by
Samuel Turpin
Browse files
Options
Downloads
Patches
Plain Diff
ajout du jeu devine nombre
parent
0148e055
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/projetjeu/autre/Jeu.java
+7
-0
7 additions, 0 deletions
src/projetjeu/autre/Jeu.java
src/projetjeu/devinelenombre/DevineNombre.java
+32
-1
32 additions, 1 deletion
src/projetjeu/devinelenombre/DevineNombre.java
with
39 additions
and
1 deletion
src/projetjeu/autre/Jeu.java
0 → 100644
+
7
−
0
View file @
c97c853f
package
projetjeu.autre
;
public
class
Jeu
{
public
static
void
main
(
String
[]
args
)
{
}
}
This diff is collapsed.
Click to expand it.
src/projetjeu/devinelenombre/DevineNombre.java
+
32
−
1
View file @
c97c853f
package
projetjeu.devinelenombre
;
package
projetjeu.devinelenombre
;
import
java.util.Random
;
import
java.util.Scanner
;
public
class
DevineNombre
public
class
DevineNombre
{
{
private
static
void
m
(
String
m
)
private
static
void
m
(
String
m
)
...
@@ -10,8 +13,36 @@ public class DevineNombre
...
@@ -10,8 +13,36 @@ public class DevineNombre
public
static
void
main
(
String
[]
args
)
public
static
void
main
(
String
[]
args
)
{
{
m
(
"Jouons à un jeu..."
);
m
(
"Jouons à un jeu..."
);
m
(
"Je vais penser à un nombre..."
);
m
(
"Je vais penser à un nombre
entre 1 et 100
..."
);
m
(
"Et toi tu devras le retrouver..."
);
m
(
"Et toi tu devras le retrouver..."
);
m
(
"Tu dispose de 5 tentatives..."
);
m
(
"Tu dispose de 5 tentatives..."
);
Random
rnd
=
new
Random
();
Scanner
sc
=
new
Scanner
(
System
.
in
);
int
nb
=
rnd
.
nextInt
(
1
,
100
);
int
lives
=
5
;
int
reponse
=
0
;
while
(
lives
!=
0
)
{
m
(
"Nombre de Vies : "
+
lives
);
reponse
=
sc
.
nextInt
();
if
(
reponse
==
nb
)
{
m
(
"Bravo tu as réussis le nombre était "
+
nb
);
lives
=
0
;
}
else
if
(
reponse
<
nb
)
{
m
(
"C'est plus !"
);
}
else
if
(
reponse
>
nb
)
{
m
(
"C'est moins !"
);
}
lives
=
lives
-
1
;
}
if
(
reponse
!=
nb
)
{
m
(
"Perdu, le nombre était "
+
nb
);
}
}
}
}
}
\ No newline at end of file
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