Advertisement
Guest User

Problem 15* Neighbour Wars.

a guest
Sep 24th, 2017
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1.  
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class ZaTriene {
  6. public static void main(String[] args) throws java.lang.Exception {
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. int peshoDamage = Integer.parseInt(scanner.nextLine());
  10. int goshoDamage = Integer.parseInt(scanner.nextLine());
  11. String pesho = "Pesho";
  12. String gosho = "Gosho";
  13. String peshoAttack = "Roundhouse kick";
  14. String goshoAttack = "Thunderous fist";
  15. int peshoHealth = 100;
  16. int goshoHealth = 100;
  17. int restoration = 10;
  18. int loopCounter = 1;
  19.  
  20. for (int i = 1; i <= loopCounter; i++) {
  21. if (peshoHealth <= 0){
  22.  
  23. loopCounter--;
  24. System.out.printf("%s won in %dth round.", gosho, loopCounter);
  25. return;
  26. }else if (goshoHealth <= 0){
  27.  
  28. loopCounter--;
  29. System.out.printf("%s won in %dth round.", pesho, loopCounter);
  30. return;
  31. }if (i % 2 != 0){
  32.  
  33. goshoHealth -= peshoDamage;
  34. if (goshoHealth > 0){
  35.  
  36. System.out.printf("%s used %s and reduced %s to %d health.", pesho, peshoAttack, gosho, goshoHealth);
  37. System.out.println();
  38. }
  39. }else{
  40.  
  41. peshoHealth -= goshoDamage;
  42. if (peshoHealth > 0){
  43.  
  44. System.out.printf("%s used %s and reduced %s to %d health.", gosho, goshoAttack, pesho, peshoHealth);
  45. System.out.println();
  46. }
  47. }if (i % 3 == 0){
  48.  
  49. goshoHealth += restoration;
  50. peshoHealth += restoration;
  51. }
  52. loopCounter++;
  53. }
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement