Advertisement
Guest User

Warior

a guest
Apr 2nd, 2020
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.31 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class lqlq {
  4.     public static void main(String[] args) {
  5.         Scanner sc = new Scanner(System.in);
  6.  
  7.         String string = sc.nextLine();
  8.         String commands = sc.nextLine();
  9.  
  10.         while (!commands.equals("For Azeroth")) {
  11.             String[] command = commands.split("\\s+");
  12.             String cases = command[0];
  13.  
  14.             switch (cases) {
  15.                 case "GladiatorStance":
  16.                     string = string.toUpperCase();
  17.                     System.out.println(String.format(string));
  18.                     break;
  19.                 case "DefensiveStance": {
  20.                     string = string.toLowerCase();
  21.                     System.out.println(String.format(string));
  22.                 }
  23.                 break;
  24.                 case "Dispel":
  25.                     int index = Integer.parseInt(command[1]);
  26.                     char letter = command[2].charAt(0);
  27.                     StringBuilder tempString = new StringBuilder(string);
  28.                     if (index >= 0 && index <= string.length() - 1) {
  29.                         tempString.setCharAt(index, letter);
  30.                         string = tempString.toString();
  31.                         System.out.println(String.format("Success!"));
  32.                     } else {
  33.                         System.out.println(String.format("Dispel too weak."));
  34.                     }
  35.                     break;
  36.                 case "Target":
  37.                     if (command[1].equals("Change")) {
  38.                         String substring = command[2];
  39.                         String substringTwo = command[3];
  40.                         string = string.replace(substring, substringTwo);
  41.                         System.out.println(String.format(string));
  42.                     } else if (command[1].equals("Remove")) {
  43.                         String substringR = command[2];
  44.                         string = string.replace(substringR, "");
  45.                         System.out.println(String.format(string));
  46.                     } else {
  47.                         System.out.println("Command doesn't exist!");
  48.                     }
  49.                     break;
  50.                 default:
  51.                     System.out.println("Command doesn't exist!");
  52.             }
  53.             commands = sc.nextLine();
  54.         }
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement