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