Partage de codes sources - CodesWall.info
Java
> Game.java
Titre
Game.java
Postée le
09-10-2008
Affichée
566
Mini-lien
Description
Game
Etat
Inconnu.
Code d'insertion
Options
Tweet
Téléchargement
public
class
Game
{
int
numberToFind
;
short
attempt
=
5
;
boolean
result
;
int
[
]
attemps
=
new
int
[
5
]
;
void
createNumber
(
int
number
)
{
int
random
=
new
Random
(
)
.
nextInt
(
number
)
;
numberToFind
=
random
;
}
void
isItTheRightNumber
(
int
number
)
{
if
(
number
<
numberToFind
)
{
System
.
out
.
println
(
"Trop petit"
)
;
}
else
if
(
number
==
numberToFind
)
{
System
.
out
.
println
(
"Gagné !"
)
;
}
else
{
System
.
out
.
println
(
"Trop grand !"
)
;
}
}
public
static
void
main
(
String
[
]
args
)
{
Game game
=
new
Game
(
)
;
game.
createNumber
(
100
)
;
Scanner scanner
=
new
Scanner
(
System
.
in
)
;
while
(
game.
result
!=
true
&&
game.
attempt
>
0
)
{
for
(
int
i
=
0
;
i
<
5
-
game.
attempt
;
i
++
)
{
System
.
out
.
println
(
"déja essayé: "
+
game.
attemps
[
i
]
)
;
}
int
typed
=
scanner.
nextInt
(
)
;
game.
attemps
[
5
-
game.
attempt
]
=
typed
;
game.
isItTheRightNumber
(
typed
)
;
game.
attempt
=
(
short
)
(
game.
attempt
-
1
)
;
}
System
.
out
.
println
(
Arrays
.
toString
(
game.
attemps
)
)
;
}
}
Postez votre code-source
Informations
Catégorie *
-
ActionScript3
ASP
C
C#.Net
C++
COBOL
CSS
Delphi
Fichier .ini
HTML4
HTML5
Java
javascript
jQuery
Latex
MatLab
mIRC
MySQL
Objective-C
OCaml
pascal
Perl
Php
Python
QBasic
Ruby
Script Batch
Shell
SmallTalk
VB.Net
VBA
Visual Basic
XML
Autre
Titre *
(50 car. max)
Description *
(200 car. max)
Le code
Fonctionne
Ne fonctionne pas
Je ne sais pas
Source
* : Champs obligatoires
Fermer
Accueil
Poster
Actualités
Règles
Contact
Partenaires
Infos / Aide
ActionScript3
(0)
ASP
(0)
C
(64)
C#.Net
(4)
C++
(51)
COBOL
(0)
CSS
(20)
Delphi
(0)
Fichier .ini
(5)
HTML4
(16)
HTML5
(0)
Java
(48)
javascript
(35)
jQuery
(0)
Latex
(6)
MatLab
(3)
mIRC
(3)
MySQL
(13)
Objective-C
(0)
OCaml
(4)
pascal
(9)
Perl
(11)
Php
(58)
Python
(0)
QBasic
(0)
Ruby
(1)
Script Batch
(8)
Shell
(10)
SmallTalk
(1)
VB.Net
(5)
VBA
(5)
Visual Basic
(6)
XML
(17)
Autre
(17)
\n
Forum informatique