Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.util.*;
- import java.util.stream.Collectors;
- public class Main {
- static int datura = 0;
- static int cherry = 0;
- static int smoke = 0;
- static boolean fullPouch = false;
- public static void main(String[] args) throws IOException {
- BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
- List<Integer> effect = Arrays.stream(reader.readLine().split(", "))
- .map(Integer::parseInt).collect(Collectors.toList());
- List<Integer> casing = Arrays.stream(reader.readLine().split(", "))
- .map(Integer::parseInt).collect(Collectors.toList());
- Collections.reverse(casing);
- while (!effect.isEmpty() && !casing.isEmpty()){
- nextBomb(effect.get(0) + casing.get(0));
- effect.remove(0);
- casing.remove(0);
- if (datura >=3 && cherry >= 3 && smoke >= 3){
- fullPouch = true;
- break;
- }
- }
- Collections.reverse(casing);
- String result = ((fullPouch) ? "Bene! You have successfully filled the bomb pouch!\n" : "You don't have enough materials to fill the bomb pouch.\n") +
- "Bomb Effects: " +
- (effect.isEmpty() ? "empty" : effect.toString().replaceAll("[\\[\\]]", "")) +
- System.lineSeparator() +
- "Bomb Casings: " +
- (casing.isEmpty() ? "empty" : casing.toString().replaceAll("[\\[\\]]", "")) +
- System.lineSeparator() +
- String.format("Cherry Bombs: %d%nDatura Bombs: %d%nSmoke Decoy Bombs: %d%n", cherry, datura, smoke);
- System.out.println(result);
- }
- private static void nextBomb(int n){
- if (n >= 120){
- smoke++;
- } else if (n >= 60){
- cherry++;
- }else if (n >= 40){
- datura++;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment