Advertisement
SIRAKOV4444

Untitled

Apr 2nd, 2020
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 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. String letter=command[2];
  27. if(index>=0 && index<=string.length()-1){
  28. String replace= String.valueOf(string.charAt(index));
  29. string=string.replace(replace,letter);
  30. System.out.println(String.format("Success!"));
  31. }else{
  32. System.out.println(String.format("Dispel too weak."));
  33. }
  34. break;
  35. case "Target":
  36. if(command[1].equals("Change")){
  37. String substring=command[2];
  38. String substringTwo=command[3];
  39. string=string.replace(substring,substringTwo);
  40. System.out.println(String.format(string));
  41. }
  42. if(command[1].equals("Remove")){
  43. String substringR=command[2];
  44. string=string.replace(substringR,"");
  45. System.out.println(String.format(string));
  46. }
  47. break;
  48. default:
  49. System.out.println("Command doesn't exist!");
  50. }
  51. commands=sc.nextLine();
  52. }
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement