Advertisement
Guest User

Untitled

a guest
Oct 3rd, 2015
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. package arrayfunc;
  2.  
  3. /**
  4. * Created by Josh on 10/3/15.
  5. */
  6. public class Pokemon {
  7. public static Double health;
  8. public static Double att;
  9. public static Double def;
  10. public static boolean alive;
  11. public static Double maxhealth;
  12. public Pokemon(Double health0, Double attack0, Double defense0) {
  13. health = health0;
  14. maxhealth = health0;
  15. att = attack0;
  16. def = defense0;
  17. alive = true;
  18. }
  19. public Double damage(Double amount) {
  20. amount *= def;
  21. health -= amount;
  22. return health;
  23. }
  24. public Double heal(Double amount) {
  25. health += amount;
  26. if (health > maxhealth) {
  27. health -= (maxhealth-health);
  28. }
  29. }
  30. public static void attack(Pokemon target, Double amount) {
  31. amount *= att;
  32. target.damage(amount);
  33. if (target.health < 0) {
  34. target.alive = false;
  35. System.out.println("The Pokemon has died.");
  36. }
  37. }
  38. public static void main(String[] args) {
  39. Pokemon squirtle = new Pokemon(50.0,0.5,0.5);
  40. squirtle.damage(27.3);
  41. System.out.println(squirtle.health);
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement