2019-01-04 20:40:11 +01:00
|
|
|
/**
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2015-09-16 14:38:46 +02:00
|
|
|
package de.vanitasvitae.enigmandroid.enigma;
|
|
|
|
|
2015-10-09 00:57:54 +02:00
|
|
|
import android.util.Log;
|
|
|
|
|
2015-10-04 22:51:35 +02:00
|
|
|
import java.math.BigInteger;
|
2015-09-26 16:04:02 +02:00
|
|
|
|
2015-10-09 00:57:54 +02:00
|
|
|
import de.vanitasvitae.enigmandroid.MainActivity;
|
Started new Iteration of MainActivity as Main2, moved getters and setters of preferences to SettingsActivity
Added Enigma KD, Added protocol version to ensure compatibility with upcoming releases, Added options to share configuration as string, organized sharing/receiving of configuration, moved preference-management to SettingsActivity, Added whats-New-Dialog that informs user about latest changes
Translated some strings, commented some methods in MainActivity
New Icon!
Added comment and removed unused import, peanuts if you ask me
Added Script to automatically render icon in all dimensions
Reformated code and moved Plugboard, EntryWheel, Reflector, Rotor to new package parts
Cleaned repository
Merge branch 'development'
2017-05-05 16:49:30 +02:00
|
|
|
import de.vanitasvitae.enigmandroid.enigma.parts.EntryWheel;
|
|
|
|
import de.vanitasvitae.enigmandroid.enigma.parts.Reflector;
|
|
|
|
import de.vanitasvitae.enigmandroid.enigma.parts.Rotor;
|
2015-09-16 14:38:46 +02:00
|
|
|
|
|
|
|
/**
|
2015-10-04 22:51:35 +02:00
|
|
|
* Implementation of the Enigma machine of name K (Switzerland, Airforce)
|
2015-09-16 14:38:46 +02:00
|
|
|
* Copyright (C) 2015 Paul Schaub
|
|
|
|
*/
|
|
|
|
public class Enigma_K_Swiss_Airforce extends Enigma_K
|
|
|
|
{
|
Started new Iteration of MainActivity as Main2, moved getters and setters of preferences to SettingsActivity
Added Enigma KD, Added protocol version to ensure compatibility with upcoming releases, Added options to share configuration as string, organized sharing/receiving of configuration, moved preference-management to SettingsActivity, Added whats-New-Dialog that informs user about latest changes
Translated some strings, commented some methods in MainActivity
New Icon!
Added comment and removed unused import, peanuts if you ask me
Added Script to automatically render icon in all dimensions
Reformated code and moved Plugboard, EntryWheel, Reflector, Rotor to new package parts
Cleaned repository
Merge branch 'development'
2017-05-05 16:49:30 +02:00
|
|
|
public Enigma_K_Swiss_Airforce()
|
|
|
|
{
|
|
|
|
super();
|
|
|
|
machineType = "KSA";
|
|
|
|
Log.d(MainActivity.APP_ID, "Created Enigma KSA");
|
|
|
|
}
|
2015-09-26 16:04:02 +02:00
|
|
|
|
Started new Iteration of MainActivity as Main2, moved getters and setters of preferences to SettingsActivity
Added Enigma KD, Added protocol version to ensure compatibility with upcoming releases, Added options to share configuration as string, organized sharing/receiving of configuration, moved preference-management to SettingsActivity, Added whats-New-Dialog that informs user about latest changes
Translated some strings, commented some methods in MainActivity
New Icon!
Added comment and removed unused import, peanuts if you ask me
Added Script to automatically render icon in all dimensions
Reformated code and moved Plugboard, EntryWheel, Reflector, Rotor to new package parts
Cleaned repository
Merge branch 'development'
2017-05-05 16:49:30 +02:00
|
|
|
@Override
|
|
|
|
protected void establishAvailableParts()
|
|
|
|
{
|
|
|
|
addAvailableEntryWheel(new EntryWheel.EntryWheel_QWERTZ());
|
|
|
|
addAvailableRotor(new Rotor.Rotor_K_Swiss_Airforce_I(0,0));
|
|
|
|
addAvailableRotor(new Rotor.Rotor_K_Swiss_Airforce_II(0,0));
|
|
|
|
addAvailableRotor(new Rotor.Rotor_K_Swiss_Airforce_III(0,0));
|
|
|
|
addAvailableReflector(new Reflector.Reflector_K_G260());
|
|
|
|
}
|
2015-10-04 22:51:35 +02:00
|
|
|
|
Started new Iteration of MainActivity as Main2, moved getters and setters of preferences to SettingsActivity
Added Enigma KD, Added protocol version to ensure compatibility with upcoming releases, Added options to share configuration as string, organized sharing/receiving of configuration, moved preference-management to SettingsActivity, Added whats-New-Dialog that informs user about latest changes
Translated some strings, commented some methods in MainActivity
New Icon!
Added comment and removed unused import, peanuts if you ask me
Added Script to automatically render icon in all dimensions
Reformated code and moved Plugboard, EntryWheel, Reflector, Rotor to new package parts
Cleaned repository
Merge branch 'development'
2017-05-05 16:49:30 +02:00
|
|
|
@Override
|
|
|
|
public BigInteger getEncodedState(int protocol_version)
|
|
|
|
{
|
|
|
|
BigInteger s = BigInteger.valueOf(reflector.getRingSetting());
|
|
|
|
s = addDigit(s, reflector.getRotation(), 26);
|
|
|
|
s = addDigit(s, rotor3.getRingSetting(),26);
|
|
|
|
s = addDigit(s, rotor3.getRotation(), 26);
|
|
|
|
s = addDigit(s, rotor2.getRingSetting(),26);
|
|
|
|
s = addDigit(s, rotor2.getRotation(), 26);
|
|
|
|
s = addDigit(s, rotor1.getRingSetting(), 26);
|
|
|
|
s = addDigit(s, rotor1.getRotation(), 26);
|
2015-10-04 22:51:35 +02:00
|
|
|
|
Started new Iteration of MainActivity as Main2, moved getters and setters of preferences to SettingsActivity
Added Enigma KD, Added protocol version to ensure compatibility with upcoming releases, Added options to share configuration as string, organized sharing/receiving of configuration, moved preference-management to SettingsActivity, Added whats-New-Dialog that informs user about latest changes
Translated some strings, commented some methods in MainActivity
New Icon!
Added comment and removed unused import, peanuts if you ask me
Added Script to automatically render icon in all dimensions
Reformated code and moved Plugboard, EntryWheel, Reflector, Rotor to new package parts
Cleaned repository
Merge branch 'development'
2017-05-05 16:49:30 +02:00
|
|
|
s = addDigit(s, rotor3.getIndex(), availableRotors.size());
|
|
|
|
s = addDigit(s, rotor2.getIndex(), availableRotors.size());
|
|
|
|
s = addDigit(s, rotor1.getIndex(), availableRotors.size());
|
|
|
|
|
|
|
|
s = addDigit(s, 9, 20); //Machine #9
|
|
|
|
s = addDigit(s, protocol_version, MainActivity.max_protocol_version);
|
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
2015-09-16 14:38:46 +02:00
|
|
|
}
|