Yargi

Bombs

Oct 20th, 2020
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.00 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStreamReader;
  4. import java.util.*;
  5. import java.util.stream.Collectors;
  6.  
  7. public class Main {
  8.  
  9.     static int datura = 0;
  10.     static int cherry = 0;
  11.     static int smoke = 0;
  12.     static boolean fullPouch = false;
  13.  
  14.     public static void main(String[] args) throws IOException {
  15.  
  16.         BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
  17.  
  18.         List<Integer> effect = Arrays.stream(reader.readLine().split(", "))
  19.                 .map(Integer::parseInt).collect(Collectors.toList());
  20.         List<Integer> casing = Arrays.stream(reader.readLine().split(", "))
  21.                 .map(Integer::parseInt).collect(Collectors.toList());
  22.         Collections.reverse(casing);
  23.  
  24.         while (!effect.isEmpty() && !casing.isEmpty()){
  25.  
  26.             nextBomb(effect.get(0) + casing.get(0));
  27.  
  28.             effect.remove(0);
  29.             casing.remove(0);
  30.  
  31.             if (datura >=3 && cherry >= 3 && smoke >= 3){
  32.                 fullPouch = true;
  33.                 break;
  34.             }
  35.         }
  36.  
  37.         Collections.reverse(casing);
  38.  
  39.         String result = ((fullPouch) ? "Bene! You have successfully filled the bomb pouch!\n" : "You don't have enough materials to fill the bomb pouch.\n") +
  40.                 "Bomb Effects: " +
  41.                 (effect.isEmpty() ? "empty" : effect.toString().replaceAll("[\\[\\]]", "")) +
  42.                 System.lineSeparator() +
  43.                 "Bomb Casings: " +
  44.                 (casing.isEmpty() ? "empty" : casing.toString().replaceAll("[\\[\\]]", "")) +
  45.                 System.lineSeparator() +
  46.                 String.format("Cherry Bombs: %d%nDatura Bombs: %d%nSmoke Decoy Bombs: %d%n", cherry, datura, smoke);
  47.         System.out.println(result);
  48.  
  49.     }
  50.  
  51.     private static void nextBomb(int n){
  52.         if (n >= 120){
  53.             smoke++;
  54.         } else if (n >= 60){
  55.             cherry++;
  56.         }else  if (n >= 40){
  57.             datura++;
  58.         }
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment