started with the TicTacToe_MinMax Project. Finished the rendering of the game.
TODO: Make a playable version and add MinMax
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
package translation_encryption;
|
||||
|
||||
public class EdabitEncription {
|
||||
|
||||
//Edabit Link
|
||||
//https://edabit.com/challenge/jfCsugyp9BSLYEtwb
|
||||
|
||||
public EdabitEncription(){ }
|
||||
|
||||
public String encrypt(String clearText){
|
||||
String editedString = new String();
|
||||
editedString = clearText.replaceAll("\\s","");
|
||||
int length = editedString.length();
|
||||
double sqrtOfLength = Math.sqrt(length);
|
||||
int columns = (int) sqrtOfLength;
|
||||
int rows = columns + 1;
|
||||
|
||||
char[][] wordtable = new char[columns][rows];
|
||||
|
||||
fillWordtable(wordtable, editedString);
|
||||
|
||||
String word = new String();
|
||||
String encrypted = new String();
|
||||
for (int i = 0; i < wordtable[0].length; i++){
|
||||
for (int j = 0; j < wordtable.length; j++){
|
||||
word += wordtable[j][i];
|
||||
}
|
||||
encrypted += word + " ";
|
||||
word = "";
|
||||
}
|
||||
|
||||
return encrypted;
|
||||
}
|
||||
|
||||
private void fillWordtable(char[][] wordtable, String text) {
|
||||
int position = 0;
|
||||
for (int i = 0; i < wordtable.length; i++){
|
||||
for (int j = 0; j < wordtable[0].length; j++){
|
||||
if (position < text.length()) {
|
||||
wordtable[i][j] = text.charAt(position);
|
||||
position++;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String decrypt(String cryptedText){
|
||||
String decrypted = new String();
|
||||
decrypted = "LOL";
|
||||
return decrypted;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
EdabitEncription encryption = new EdabitEncription();
|
||||
String clearText = "Info ist ein wenig langweilig";
|
||||
String encrypted = encryption.encrypt(clearText);
|
||||
System.out.println(encrypted);
|
||||
String decrypted = encryption.decrypt(encrypted);
|
||||
if (decrypted.equals(clearText)){
|
||||
System.out.println("The Encryption was successful!");
|
||||
} else {
|
||||
System.out.println("You made a mistake.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package translation_encryption;
|
||||
|
||||
public class KaracasEncryption {
|
||||
|
||||
//Edabit-Challange
|
||||
//https://edabit.com/challenge/SmL32HnRnmsCqGC5g
|
||||
|
||||
public KaracasEncryption(){
|
||||
|
||||
}
|
||||
|
||||
public String replaceVowles(String reversedText){
|
||||
String tempText = new String();
|
||||
for (int i = 0; i < reversedText.length(); i++){
|
||||
char c = reversedText.charAt(i);
|
||||
switch (c){
|
||||
case 'a':
|
||||
tempText += 0;
|
||||
break;
|
||||
case 'e':
|
||||
tempText+= 1;
|
||||
break;
|
||||
case 'o':
|
||||
tempText += 2;
|
||||
break;
|
||||
case 'u':
|
||||
tempText += 3;
|
||||
break;
|
||||
default:
|
||||
tempText += reversedText.charAt(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
tempText += "aca";
|
||||
return tempText;
|
||||
}
|
||||
|
||||
public String reverseString(String clearText){
|
||||
String tempText = new String();
|
||||
for (int i = clearText.length()-1; i >= 0; i--){
|
||||
tempText += clearText.charAt(i);
|
||||
}
|
||||
return tempText;
|
||||
}
|
||||
|
||||
public String encrypt(String clearText){
|
||||
String reversed = reverseString(clearText);
|
||||
String fullencrypted = replaceVowles(reversed);
|
||||
return fullencrypted;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
KaracasEncryption karacas = new KaracasEncryption();
|
||||
karacas.encrypt("alpaca");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package translation_encryption;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class PigLatinTranslation {
|
||||
|
||||
//Edabit-Challange
|
||||
//https://edabit.com/challenge/2aajqTB69y7ZSSo9v
|
||||
|
||||
public static String pigLatin(String str) {
|
||||
String[] words = str.split("\\s|(?=[!\\.?])");
|
||||
String returnString = "";
|
||||
for (int i = 0; i < words.length-1; i++) {
|
||||
String s = "";
|
||||
|
||||
if ("AEIOUaeiou".indexOf(words[i].charAt(0)) == -1) {
|
||||
if (i == 0) {
|
||||
if (words[i].length() > 1) {
|
||||
s = words[i].toUpperCase().charAt(1) + words[i].substring(2) + words[i].toLowerCase().charAt(0);
|
||||
} else {
|
||||
s = words[i].toUpperCase();
|
||||
}
|
||||
} else {
|
||||
if (words[i].length() > 2) {
|
||||
s = words[i].substring(1) + words[i].toLowerCase().charAt(0);
|
||||
} else if (words[i].length() == 2) {
|
||||
s = words[i].toLowerCase().charAt(1) + String.valueOf(words[i].toLowerCase().charAt(0));
|
||||
} else {
|
||||
s = words[i].toLowerCase();
|
||||
}
|
||||
}
|
||||
s += "ay";
|
||||
} else {
|
||||
s += words[i] + "way";
|
||||
}
|
||||
|
||||
if (i < words.length-2) {
|
||||
returnString += s + " ";
|
||||
} else{
|
||||
returnString += s + words[i+1];
|
||||
}
|
||||
}
|
||||
return returnString;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(pigLatin("Tom got a small piece of pie."));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user