mirror of
https://github.com/vanitasvitae/EnigmAndroid.git
synced 2024-11-25 22:02:07 +01:00
Fix #4; Catch non-alphabetic input in the plugboard.
This commit is contained in:
parent
449c80ebd5
commit
965aee43dd
3 changed files with 14 additions and 6 deletions
|
@ -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 {
|
||||||
|
|
|
@ -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)
|
||||||
{
|
{
|
||||||
|
@ -177,9 +178,15 @@ public class Enigma
|
||||||
//If it does
|
//If it does
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//add it to the array
|
char[] pair = x.toCharArray();
|
||||||
plugs[i] = x.toCharArray();
|
//Check, if Plugs are in alphabet
|
||||||
i++;
|
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
|
||||||
|
plugs[i] = pair;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return plugs;
|
return plugs;
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue