-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ff54c0e
commit 5f39c95
Showing
3 changed files
with
92 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package nz.ac.eit; | ||
|
||
public class Converter { | ||
String[] frenchNumbers = {"un", "deux", "trois", "quatre", "cinq", "six", "sept", "huit", "neuf", | ||
"dix", "onze", "douze", "treize", "quatorze", "quinze", "seize", "dix-sept", "dix-huit", "dix-neuf", | ||
"vingt", "vingt et un", "vingt-deux", "vingt-trois", "vingt-quatre", "vingt-cinq", "vingt-six", | ||
"vingt-sept", "vingt-huit", "vingt-neuf", "trente"}; | ||
|
||
String[] germanNumbers = {"einz", "zwei", "drei", "vier", "funf", "sechs", "sieben", "acht", "neun", | ||
"zehn", "elf", "zwolf", "dreizehn", "vierzehn", "funfzehn", "sechzehn", "siebzehn", "achtzehn", | ||
"neunzehn", "zwanzig", "einundzwanzig", "zweiundzwanzig", "dreiundzwanzig", "vierundzwanzig", | ||
"fünfundzwanzig", "sechsundzwanzig", "siebenundzwanzig", "achtundzwanzig", "neunundzwanzig", "dreiβig"}; | ||
|
||
public String convert(int number, String chosenLanguage){ | ||
try { | ||
if (chosenLanguage.equalsIgnoreCase("French")) { | ||
return frenchNumbers[number - 1]; | ||
} | ||
if (chosenLanguage.equalsIgnoreCase("German")) { | ||
return germanNumbers[number - 1]; | ||
} | ||
return null; | ||
}catch(Exception e){ | ||
return null; | ||
} | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package nz.ac.eit; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
public class Converter_Test { | ||
private Converter conv; | ||
@Before | ||
public void setup(){ | ||
conv = new Converter(); | ||
} | ||
|
||
@Test | ||
public void test_1toGerman_Einz() { | ||
|
||
String translated = conv.convert(1,"german"); | ||
assertEquals("1 is not giving einz","einz",translated); | ||
} | ||
|
||
@Test | ||
public void test_1toFrench_Un() { | ||
|
||
String translated = conv.convert(1,"french"); | ||
assertEquals("1 is not giving un","un",translated); | ||
} | ||
|
||
@Test | ||
public void test_Neg5toFrench_Null() { | ||
|
||
String translated = conv.convert(-5,"french"); | ||
assertEquals("1 is not giving null",null,translated); | ||
} | ||
|
||
@Test | ||
public void test_Neg10toGerman_Null() { | ||
|
||
String translated = conv.convert(-10,"german"); | ||
assertEquals("1 is not giving null",null,translated); | ||
} | ||
|
||
|
||
|
||
} |