-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEncrypt this!.java
More file actions
44 lines (42 loc) · 1.14 KB
/
Encrypt this!.java
File metadata and controls
44 lines (42 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package katatemplateproject;
import java.util.Arrays;
public class KataTemplateProject {
public static void main(String[] args) {
prnt(Kata.encryptThis(""));
}
public static <T> void prnt(T args){
System.out.println(args);
}
}
class Kata {
public static String encryptThis(String text) {
String[] spltext = text.split(" ");
char[][] ch = new char[spltext.length][];
for(int i=0;i<spltext.length;i++){
ch[i]=spltext[i].toCharArray();
}
String s="";
int a=0;
for(int i=0;i<spltext.length;i++){
for(int j=0;j<ch[i].length;j++){
if(j==0){
a=ch[i][j];
s+=a;
}
else if(j==1){
char buffer=ch[i][j];
ch[i][j]=ch[i][ch[i].length-1];
ch[i][ch[i].length-1]=buffer;
s+=ch[i][j];
}
else{
s+=ch[i][j];
}
}
if(i!=spltext.length-1){
s+=" ";
}
}
return s;
}
}