Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Test;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Scanner;
- public class Third {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- String[] tokens = scan.nextLine().split(", ");
- List<String> journal = new ArrayList<>();
- for (int i = 0; i < tokens.length; i++) {
- journal.add(tokens[i]);
- }
- String input = scan.nextLine();
- while (!"Craft!".equals(input)){
- tokens = input.split(" - ");
- if (tokens[0].equals("Collect")){
- if (!journal.contains(tokens[1])){
- journal.add(tokens[1]);
- }
- }else if (tokens[0].equals("Drop")){
- if (journal.contains(tokens[1])){
- journal.remove(tokens[1]);
- }
- }else if (tokens[0].equals("Combine Items")){
- String[] command = tokens[1].split("\\:");
- if (journal.contains(command[0])){
- int index = journal.indexOf(command[0]);
- journal.add(index + 1, command[1]);
- }
- }else if (tokens[0].equals("Renew")){
- if (journal.contains(tokens[1])){
- journal.remove(tokens[1]);
- journal.add(tokens[1]);
- }
- }
- input = scan.nextLine();
- }
- System.out.println(String.join(", ", journal));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement