Fix #4; Catch non-alphabetic input in the plugboard.

This commit is contained in:
vanitasvitae 2015-02-23 18:19:37 +01:00
parent 449c80ebd5
commit 965aee43dd
3 changed files with 14 additions and 6 deletions

View file

@ -8,8 +8,8 @@ android {
applicationId "de.vanitasvitae.enigmandroid" applicationId "de.vanitasvitae.enigmandroid"
minSdkVersion 15 minSdkVersion 15
targetSdkVersion 21 targetSdkVersion 21
versionCode 6 versionCode 7
versionName "0.1.1-18.02.2015-beta" versionName "0.1.1-23.02.2015-beta"
} }
buildTypes { buildTypes {
release { release {

View file

@ -148,6 +148,7 @@ public class Enigma
*/ */
public static char[][] parsePlugs(String p) throws InvalidPlugboardConfigurationFormatException public static char[][] parsePlugs(String p) throws InvalidPlugboardConfigurationFormatException
{ {
p = p.toUpperCase();
//Check, if empty //Check, if empty
if (p.length() == 0) if (p.length() == 0)
{ {
@ -176,12 +177,18 @@ public class Enigma
} }
//If it does //If it does
else else
{
char[] pair = x.toCharArray();
//Check, if Plugs are in alphabet
if(pair[0]<65 || pair[1]<65 || pair[0]>90 || pair[1]>90) throw new InvalidPlugboardConfigurationFormatException("Error parsing plugs! Maybe you entered a number or a special character?");
else
{ {
//add it to the array //add it to the array
plugs[i] = x.toCharArray(); plugs[i] = pair;
i++; i++;
} }
} }
}
return plugs; return plugs;
} }
} }

View file

@ -19,9 +19,10 @@ Features:
* Working plugboard * Working plugboard
More Information about the historical Enigma can be found on Wikipedia.org More Information about the historical Enigma can be found on Wikipedia.org
(I recommend the german article, since it is very detailed.)
. .
Repo Type: git Repo Type: git
Build:0.1.1-18.02.2015-beta,6 Build:0.1.1-23.02.2015-beta,7
Auto Update Mode:None Auto Update Mode:None
Update Check Mode:None Update Check Mode:None