Commit f0f2855a authored by Romain's avatar Romain

almost final update

parent 65993b52
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);
}
......
......@@ -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
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment