mardi 3 mars 2015

Replacing String in the original String only

During my program I am allowing a user to input a string. But then it also replaces the things in the output, so all I want it to do is replace in the original string. Thank you.



public class Crypto {
public Crypto() {
String s = f;
}

public String encrypt(String s) {

String myString = s.replace("v", "ag\'r").replace("V", "ag\'r")
.replace("m", "ssad").replace("M", "ssad")
.replace("g", "jeb..w").replace("G", "jeb..w")
.replace("b", "dug?/").replace("B", "dug?/");
return myString;
}

public String decrypt(String d) {
String myString = d.replace("ag‘,r", "v").replace("ssad", "m")
.replace("jeb..w", "g").replace("dug>?/", "b");
return myString;
}

public String d;
public String s;
public String f;
public String myString;
}

Aucun commentaire:

Enregistrer un commentaire