Advertisement
4valeri

01.TinySporebat

Apr 3rd, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.60 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class _01TinySporebat26Oct15 {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner scan = new Scanner(System.in);
  9.  
  10.         int health = 5800;
  11.         int currentHelth = 0;
  12.         String reader = scan.nextLine();
  13.         int glowCaps = 30;
  14.         int currentGlowCaps = 0;
  15.  
  16.         while (!reader.equals("Sporeggar")) {
  17.  
  18.             for (int i = 0; i < reader.length() - 1; i++) {
  19.                     if (reader.charAt(i) == 'L') {
  20.                         health += 200;
  21.                     }
  22.                     else {
  23.                         currentHelth += (reader.charAt(i));
  24.                     }
  25.             }
  26.  
  27.                 if ((health - currentHelth) <= 0) {
  28.                     break;
  29.                 }
  30.             currentGlowCaps += Integer.parseInt(reader.charAt(reader.length() - 1) + "");
  31.             reader = scan.nextLine();
  32.         }
  33.  
  34.         if ((health - currentHelth) > 0) {
  35.             System.out.printf("Health left: %s", health - currentHelth);
  36.             System.out.println();
  37.             if ((30 - currentGlowCaps) > 0 ) {
  38.                 System.out.printf("Safe in Sporeggar, but another %s Glowcaps needed.", glowCaps - currentGlowCaps);
  39.                 System.out.println();
  40.             }
  41.             else {
  42.                 System.out.printf("Bought the sporebat. Glowcaps left: %s", Math.abs(glowCaps - currentGlowCaps));
  43.                 System.out.println();
  44.             }
  45.         }
  46.  
  47.         else {
  48.             System.out.printf("Died. Glowcaps: %s", currentGlowCaps);
  49.  
  50.         }
  51.     }
  52.  
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement