Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
assessment part 4
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
romain.vasseur
assessment part 4
Commits
65993b52
Commit
65993b52
authored
Dec 05, 2018
by
Romain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
abc9a5be
Pipeline
#425
failed with stages
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
115 additions
and
7 deletions
+115
-7
AssessmentPartFour.java
src/AssessmentPartFour.java
+114
-6
AssessmentPartFourTest.java
src/AssessmentPartFourTest.java
+1
-1
No files found.
src/AssessmentPartFour.java
View file @
65993b52
...
@@ -21,10 +21,10 @@ public class AssessmentPartFour {
...
@@ -21,10 +21,10 @@ public class AssessmentPartFour {
number
=
0
;
number
=
0
;
while
(
scanner
.
hasNextLine
())
{
while
(
scanner
.
hasNextLine
())
{
String
line
=
scanner
.
nextLine
();
String
line
=
scanner
.
nextLine
();
System
.
out
.
println
(
line
);
morseCode
.
add
(
line
);
morseCode
.
add
(
line
);
// Faites ici votre traitement.
// Faites ici votre traitement.
System
.
out
.
println
(
morseCode
.
size
());
number
=
morseCode
.
size
();
number
=
morseCode
.
size
();
}
}
...
@@ -37,15 +37,123 @@ public class AssessmentPartFour {
...
@@ -37,15 +37,123 @@ public class AssessmentPartFour {
}
}
public
String
translateMorse
(
)
public
String
translateMorse
(
String
filename
)
/*add String filename in () */
{
{
List
<
String
>
morseCode
=
new
ArrayList
<
String
>();
char
[]
to
=
new
char
[
loadMorseFromFile
(
filename
)];
try
(
Scanner
scanner
=
new
Scanner
(
new
File
(
filename
)))
{
// On boucle sur chaque champ détecté.
while
(
scanner
.
hasNextLine
())
{
String
line
=
scanner
.
nextLine
();
morseCode
.
add
(
line
);
return
""
;
}
}
for
(
int
i
=
0
;
i
<
morseCode
.
size
();
i
++)
{
to
[
i
]=
morseToEnglish
(
morseCode
.
get
(
i
));
}
}
catch
(
FileNotFoundException
ex
)
{
System
.
out
.
println
(
"Erreur --"
+
ex
.
toString
());
}
System
.
out
.
println
(
new
String
(
to
));
return
new
String
(
to
);
}
private
static
char
morseToEnglish
(
String
a
)
{
char
morse
;
char
alphabet
=
0
;
switch
(
a
)
{
case
".-"
:
alphabet
=
'a'
;
break
;
case
"-..."
:
alphabet
=
'b'
;
break
;
case
"-.-."
:
alphabet
=
'c'
;
break
;
case
"-.."
:
alphabet
=
'd'
;
break
;
case
"."
:
alphabet
=
'e'
;
break
;
case
"..-."
:
alphabet
=
'f'
;
break
;
case
"--."
:
alphabet
=
'g'
;
break
;
case
"...."
:
alphabet
=
'h'
;
break
;
case
".."
:
alphabet
=
'i'
;
break
;
case
".---"
:
alphabet
=
'j'
;
break
;
case
"-.-"
:
alphabet
=
'k'
;
break
;
case
".-.."
:
alphabet
=
'l'
;
break
;
case
"--"
:
alphabet
=
'm'
;
break
;
case
"-."
:
alphabet
=
'n'
;
break
;
case
"---"
:
alphabet
=
'o'
;
break
;
case
".--."
:
alphabet
=
'p'
;
break
;
case
"--.-"
:
alphabet
=
'q'
;
break
;
case
".-."
:
alphabet
=
'r'
;
break
;
case
"..."
:
alphabet
=
's'
;
break
;
case
"-"
:
alphabet
=
't'
;
break
;
case
"..-"
:
alphabet
=
'u'
;
break
;
case
"...-"
:
alphabet
=
'v'
;
break
;
case
".--"
:
alphabet
=
'w'
;
break
;
case
"-..-"
:
alphabet
=
'x'
;
break
;
case
"-.--"
:
alphabet
=
'y'
;
break
;
case
"--.."
:
alphabet
=
'z'
;
break
;
case
".----"
:
alphabet
=
'1'
;
break
;
case
"..---"
:
alphabet
=
'2'
;
break
;
case
"...--"
:
alphabet
=
'3'
;
break
;
case
"....-"
:
alphabet
=
'4'
;
break
;
case
"....."
:
alphabet
=
'5'
;
break
;
case
"-...."
:
alphabet
=
'6'
;
break
;
case
"--..."
:
alphabet
=
'7'
;
break
;
case
"---.."
:
alphabet
=
'8'
;
break
;
case
"----."
:
alphabet
=
'9'
;
break
;
case
"-----"
:
alphabet
=
'0'
;
break
;
case
"/"
:
alphabet
=
' '
;
break
;
}
morse
=
alphabet
;
return
morse
;
}
}
}
src/AssessmentPartFourTest.java
View file @
65993b52
...
@@ -41,7 +41,7 @@ class AssessmentPartFourTest {
...
@@ -41,7 +41,7 @@ class AssessmentPartFourTest {
int
cc
=
test
.
loadMorseFromFile
(
filename
);
int
cc
=
test
.
loadMorseFromFile
(
filename
);
if
(
cc
==
count
)
if
(
cc
==
count
)
{
{
assertEquals
(
message
,
test
.
translateMorse
(
));
assertEquals
(
message
,
test
.
translateMorse
(
filename
));
// add filename in ()
}
}
else
else
{
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment