import java.util.Random; public class KlingStarShip extends StarShip { public static final char DEFAULT_APPEARANCE = 'K'; public static final int MAX_DIE_ROLL = 12; public static final int DIE_ROLL_BOOSTER = 1; public static final int NUM_DICE = 20; public KlingStarShip() { super(); setAppearance(DEFAULT_APPEARANCE); } /* Fed StarShip inflicts 20 - 240 damage per attack = 1-12 (one die) * 20 dice */ public int attack() { System.out.println("<<< KlingStarShip.attack() >>>"); Random aGenerator = new Random(); int i = 0; int tempDamage = 0; int totalDamage = 0; for (i = 0; i < NUM_DICE; i++) { // Roll single die tempDamage = aGenerator.nextInt(MAX_DIE_ROLL) + DIE_ROLL_BOOSTER; // Add that die's damage to running total totalDamage = totalDamage + tempDamage; } return(totalDamage); } public void utterBattleCry() { System.out.println("Heghlu'meH QaQ jajvam!"); } }