public abstract class Pokemon { protected static int antPokemon; protected int hp; protected int angrep; protected int id; // Legg til konstruktør (Da må super benyttes i subklassene!) // Legg til en id public Pokemon(int hp, int angrep) { this.hp = hp; this.angrep = angrep; this.id = antPokemon; // Vær nøye med hva som skjer her! antPokemon++; } public void angrip(Pokemon offer) { System.out.println("\n" + this + " angriper " + offer + "!"); offer.taSkade(this, angrep); } // Denne kan endres! protected void taSkade(Pokemon angriper, int skade) { hp -= skade; System.out.println(this + " har " + hp + " hp igjen"); if (hp <= 0) { System.out.println(this + " besvimte!"); } // ^ ^ ^ // | | | /* if (angriper instanceof FlammeType && this instanceof VannType) { hp -= skade*0.5; } else { hp -= skade; } System.out.println(this + " har " + hp + " hp igjen"); if (hp <= 0) { System.out.println(this + " besvimte!"); } */ } public int antPokemon() { return antPokemon; } // Legg til en snakk()-metode public void snakk() { System.out.println("Abstrakte Pokemons kan ikke snakke!"); } // Legg til toString() i Pokemon også // Vis hva som skjer hvis den ikke er public public String toString() { return "Dette er en pokemon"; } public void info() { System.out.println("#" + id + " " + this + " | " + hp + " HP"); } }