Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package arrayfunc;
- /**
- * Created by Josh on 10/3/15.
- */
- public class Pokemon {
- public static Double health;
- public static Double att;
- public static Double def;
- public static boolean alive;
- public static Double maxhealth;
- public Pokemon(Double health0, Double attack0, Double defense0) {
- health = health0;
- maxhealth = health0;
- att = attack0;
- def = defense0;
- alive = true;
- }
- public Double damage(Double amount) {
- amount *= def;
- health -= amount;
- return health;
- }
- public Double heal(Double amount) {
- health += amount;
- if (health > maxhealth) {
- health -= (maxhealth-health);
- }
- }
- public static void attack(Pokemon target, Double amount) {
- amount *= att;
- target.damage(amount);
- if (target.health < 0) {
- target.alive = false;
- System.out.println("The Pokemon has died.");
- }
- }
- public static void main(String[] args) {
- Pokemon squirtle = new Pokemon(50.0,0.5,0.5);
- squirtle.damage(27.3);
- System.out.println(squirtle.health);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement