Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class lqlq {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- String string = sc.nextLine();
- String commands=sc.nextLine();
- while (!commands.equals("For Azeroth")){
- String[]command=commands.split("\\s+");
- String cases=command[0];
- switch (cases){
- case"GladiatorStance":
- string=string.toUpperCase();
- System.out.println(String.format(string));
- break;
- case"DefensiveStance": {
- string = string.toLowerCase();
- System.out.println(String.format(string));
- }
- break;
- case"Dispel":
- int index=Integer.parseInt(command[1]);
- String letter=command[2];
- if(index>=0 && index<=string.length()-1){
- String replace= String.valueOf(string.charAt(index));
- string=string.replace(replace,letter);
- System.out.println(String.format("Success!"));
- }else{
- System.out.println(String.format("Dispel too weak."));
- }
- break;
- case "Target":
- if(command[1].equals("Change")){
- String substring=command[2];
- String substringTwo=command[3];
- string=string.replace(substring,substringTwo);
- System.out.println(String.format(string));
- }
- if(command[1].equals("Remove")){
- String substringR=command[2];
- string=string.replace(substringR,"");
- System.out.println(String.format(string));
- }
- break;
- default:
- System.out.println("Command doesn't exist!");
- }
- commands=sc.nextLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement