public class Weapon // represents a weapon in the adventure game, each creature will have a weapon to wield with different specifications { private String type; // represents the type of weapon (e.g., "sword") private int attacksPerTurn, minDamage, maxDamage; // specifications about this weapon public Weapon() // no-arg constructor, assume minimal weapon { type="unknown"; attacksPerTurn=1; minDamage=1; maxDamage=1; } public Weapon(String t, int n, int mn, int mx) { type=t; attacksPerTurn=n; minDamage=mn; maxDamage=mx; } // accessors public String getWeapon() {return type;} public int getAttacks() {return attacksPerTurn;} public int getMinDamage() {return minDamage;} public int getMaxDamage() {return maxDamage;} public boolean isBetter(Weapon other) // determine if other is better than this weapon { // cannot take weapon that is part of a body if(other.getWeapon().equals("Venom")||other.getWeapon().equals("Hands")||other.getWeapon().equals("Claws")) return false; else { // otherwise test average damage of this.weapon and other double avg1=((double)attacksPerTurn)*(maxDamage-minDamage); double avg2=((double)other.getAttacks())*(other.getMaxDamage()-other.getMinDamage()); if(avg2>avg1) return true; else return false; } } }