Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Arrays;
- public class CipherText {
- private static String cipherCode = "CĆDEĘFGHIJKLŁMNŃOÓPRSŚTUWYZŹŻAĄB";
- private static String alfabet = "AĄBCĆDEĘFGHIJKLŁMNŃOÓPRSŚTUWYZŹŻ";
- private static char[] CipherArray = new char[cipherCode.length()];
- private static char[] AlfabetArray = new char[alfabet.length()];
- public static String cipher(String msg, int shift){
- for(int i = 0; i < cipherCode.length();i++){
- CipherArray[i] = (char) (cipherCode.charAt(i));
- AlfabetArray[i] = (char) (alfabet.charAt(i));
- }
- String s = "";
- int len = msg.length();
- for(int x = 0; x < len; x++){
- char z = (char)(msg.charAt(x));
- if(z == ' '){
- s += " ";
- }
- else if(z != ' '){
- for(int i = 0 ; i < AlfabetArray.length;i++){
- if(z == AlfabetArray[i]){
- s+= CipherArray[i];
- }
- }
- }
- }
- return s;
- }
- }
- public class GlownaKlasa {
- public static void main(String[] args){
- String text = "Ala ma kota";
- String code = CipherText.cipher("Ato niespodzianka", 3);
- System.out.println(code);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement