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
f0f2855a
Commit
f0f2855a
authored
Dec 06, 2018
by
Romain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
almost final update
parent
65993b52
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
30 deletions
+18
-30
AssessmentPartFour.java
src/AssessmentPartFour.java
+17
-29
AssessmentPartFourTest.java
src/AssessmentPartFourTest.java
+1
-1
No files found.
src/AssessmentPartFour.java
View file @
f0f2855a
import
java.io.BufferedReader
;
import
java.io.File
;
import
java.io.FileNotFoundException
;
import
java.io.FileReader
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Scanner
;
public
class
AssessmentPartFour
{
List
<
String
>
morseCode
=
new
ArrayList
<
String
>();
public
int
loadMorseFromFile
(
String
filename
)
{
int
number
=
0
;
List
<
String
>
morseCode
=
new
ArrayList
<
String
>();
try
(
Scanner
scanner
=
new
Scanner
(
new
File
(
filename
)))
{
// On boucle sur chaque champ détecté.
morseCode
.
clear
();
try
{
Scanner
scanner
=
new
Scanner
(
new
File
(
filename
));
try
{
number
=
0
;
while
(
scanner
.
hasNextLine
())
{
String
line
=
scanner
.
nextLine
();
morseCode
.
add
(
line
);
// Faites ici votre traitement.
number
=
morseCode
.
size
();
}
}
}
finally
{
scanner
.
close
();
}
}
catch
(
FileNotFoundException
ex
)
{
System
.
out
.
println
(
"Erreur --"
+
ex
.
toString
());
}
...
...
@@ -37,29 +38,16 @@ public class AssessmentPartFour {
}
public
String
translateMorse
(
String
filename
)
/*add String filename in () */
public
String
translateMorse
(
)
{
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
);
}
for
(
int
i
=
0
;
i
<
morseCode
.
size
();
i
++)
char
[]
to
=
new
char
[
morseCode
.
size
()];
for
(
int
i
=
0
;
i
<
morseCode
.
size
();
i
++)
{
to
[
i
]=
morseToEnglish
(
morseCode
.
get
(
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
);
}
...
...
src/AssessmentPartFourTest.java
View file @
f0f2855a
...
...
@@ -41,7 +41,7 @@ class AssessmentPartFourTest {
int
cc
=
test
.
loadMorseFromFile
(
filename
);
if
(
cc
==
count
)
{
assertEquals
(
message
,
test
.
translateMorse
(
filename
));
// add filename in ()
assertEquals
(
message
,
test
.
translateMorse
(
));
}
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