Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MyClass {
- public static void main(String args[]) {
- java.util.Scanner scanner = new java.util.Scanner(System.in);
- String firstInput = scanner.nextLine();
- String currentInput = "";
- while(true) {
- currentInput = scanner.nextLine();
- if(currentInput.equals("Decode")) {
- System.out.printf("The decrypted message is: %s",firstInput);
- break;
- //to-do
- }
- String[] stringArr = currentInput.split("\\|");
- switch(stringArr[0]) {
- case "Move" : String p1 = firstInput.substring(0,Integer.parseInt(stringArr[1])); firstInput = firstInput.substring(Integer.parseInt(stringArr[1])) + p1; break;
- case "Insert" : String p2 = firstInput.substring(0,Integer.parseInt(stringArr[1])); firstInput = p2 + stringArr[2] + firstInput.substring(Integer.parseInt(stringArr[1])); break;
- case "ChangeAll" : firstInput = firstInput.replaceAll(stringArr[1],stringArr[2]); break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement