Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
poo2019numeric
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
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
steven.liatti
poo2019numeric
Merge requests
!1
David
Code
Review changes
Check out branch
Download
Patches
Plain diff
Open
David
david.carballo/poo2019numeric:David
into
master
Overview
0
Commits
30
Pipelines
0
Changes
10
Open
david.carballo
requested to merge
david.carballo/poo2019numeric:David
into
master
5 years ago
Overview
0
Commits
30
Pipelines
0
Changes
10
Expand
merge de david vers master
0
0
Merge request reports
Compare
master
version 3
1319b616
5 years ago
version 2
9a1b1519
5 years ago
version 1
abbc94b6
5 years ago
master (base)
and
latest version
latest version
7d576dc9
30 commits,
5 years ago
version 3
1319b616
29 commits,
5 years ago
version 2
9a1b1519
11 commits,
5 years ago
version 1
abbc94b6
10 commits,
5 years ago
10 files
+
707
−
60
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
10
Search (e.g. *.vue) (Ctrl+P)
src/main/java/ch/hepia/hangman/Hangman.java
0 → 100644
+
138
−
0
Options
package
ch.hepia.hangman
;
public
class
Hangman
{
/*
currentWord = l'avancement actuel du mot ex : _a___ == David
guessWord = le mot rechercher ex David
letter = la lettre entrers
Ex :
currentWord = _____
guessWord = David
letter = 'a'
resultat = _a____
*/
public
static
String
check
(
String
currentWord
,
String
guessWord
,
char
letter
)
{
//les string sont immutable en java
//conversion en tableau de char
char
[]
tempArray
=
currentWord
.
toCharArray
();
for
(
int
i
=
0
;
i
<
guessWord
.
length
();
i
++)
{
if
(
guessWord
.
charAt
(
i
)==
letter
)
//a ajouter les test majuscule
{
tempArray
[
i
]=
letter
;
}
}
return
String
.
valueOf
(
tempArray
);
}
/*
guessWord = le mot a cacher
Ex :
guessWord = David
resultat = ______
*/
public
static
String
createWord
(
String
guessWord
)
{
char
tempArray
[]=
guessWord
.
toCharArray
();
for
(
int
i
=
0
;
i
<
guessWord
.
length
();
i
++)
{
tempArray
[
i
]=
'_'
;
}
return
String
.
valueOf
(
tempArray
);
}
/*
Affiche l'etat de la potence en fonction du nombre d'essai.
*/
public
static
void
print
(
int
essai
)
{
String
pot
=
""
;
pot
=
pot
.
concat
(
"----------\n"
);
switch
(
essai
)
{
case
1
:
pot
=
pot
.
concat
(
"|/\n"
);
for
(
int
i
=
0
;
i
<
6
;
i
++)
{
pot
=
pot
.
concat
(
"|\n"
);
}
break
;
case
2
:
pot
=
pot
.
concat
(
"|/ |\n"
);
for
(
int
i
=
0
;
i
<
6
;
i
++)
{
pot
=
pot
.
concat
(
"|\n"
);
}
break
;
case
3
:
pot
=
pot
.
concat
(
"|/ |\n"
);
pot
=
pot
.
concat
(
"| (_)\n"
);
for
(
int
i
=
0
;
i
<
5
;
i
++)
{
pot
=
pot
.
concat
(
"|\n"
);
}
break
;
case
4
:
pot
=
pot
.
concat
(
"|/ |\n"
);
pot
=
pot
.
concat
(
"| (_)\n"
);
pot
=
pot
.
concat
(
"| |\n"
);
for
(
int
i
=
0
;
i
<
4
;
i
++)
{
pot
=
pot
.
concat
(
"|\n"
);
}
break
;
case
5
:
pot
=
pot
.
concat
(
"|/ |\n"
);
pot
=
pot
.
concat
(
"| (_)\n"
);
pot
=
pot
.
concat
(
"| /|\n"
);
for
(
int
i
=
0
;
i
<
4
;
i
++)
{
pot
=
pot
.
concat
(
"|\n"
);
}
break
;
case
6
:
pot
=
pot
.
concat
(
"|/ |\n"
);
pot
=
pot
.
concat
(
"| (_)\n"
);
pot
=
pot
.
concat
(
"| /|\\\n"
);
for
(
int
i
=
0
;
i
<
4
;
i
++)
{
pot
=
pot
.
concat
(
"|"
);
}
break
;
case
7
:
pot
=
pot
.
concat
(
"|/ |\n"
);
pot
=
pot
.
concat
(
"| (_)\n"
);
pot
=
pot
.
concat
(
"| /|\\\n"
);
pot
=
pot
.
concat
(
"| | \n"
);
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
pot
=
pot
.
concat
(
"|"
);
}
break
;
case
8
:
pot
=
pot
.
concat
(
"|/ |\n"
);
pot
=
pot
.
concat
(
"| (_)\n"
);
pot
=
pot
.
concat
(
"| /|\\\n"
);
pot
=
pot
.
concat
(
"| | \n"
);
pot
=
pot
.
concat
(
"| / \n"
);
for
(
int
i
=
0
;
i
<
2
;
i
++)
{
pot
=
pot
.
concat
(
"|"
);
}
break
;
case
9
:
pot
=
pot
.
concat
(
"|/ |\n"
);
pot
=
pot
.
concat
(
"| (_)\n"
);
pot
=
pot
.
concat
(
"| /|\\\n"
);
pot
=
pot
.
concat
(
"| | \n"
);
pot
=
pot
.
concat
(
"| / \\\n"
);
for
(
int
i
=
0
;
i
<
2
;
i
++)
{
pot
=
pot
.
concat
(
"|\n"
);
}
break
;
}
System
.
out
.
print
(
pot
);
}
}
Loading