Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- import java.util.regex.Matcher;
- import java.util.regex.Pattern;
- public class Boss_Rush {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- Pattern pattern = Pattern.compile("(?<bossName>\\|[A-Z]+\\|):#(?<title>[A-Z][a-z]+ \\w+#)");
- int n = Integer.parseInt(scanner.nextLine());
- for (int i = 0; i < n; i++) {
- String input = scanner.nextLine();
- Matcher matcher = pattern.matcher(input);
- if (matcher.find()) {
- System.out.println();
- String bossName = matcher.group("bossName");
- String title = matcher.group("title");
- String removeSymbol = title.substring(title.length() - 1, title.length());
- System.out.printf("%s, The %s%n", bossName.replace("|", "")
- , title.replace(removeSymbol, ""));
- System.out.printf(">> Strength: %d%n>> Armour: %d", bossName.length() - 2, title.length() - 1);
- System.out.println();
- } else {
- System.out.print("Access denied!");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement