package main; import java.awt.FontMetrics; import java.awt.Font; import java.awt.Graphics; import java.awt.Point; import utils.DynamicImage; public class Armor extends Item { private int armorRating; private ArmorType type; public Armor(final String name, final DynamicImage img, final ArmorType type, final int armorRating) { super(name, img, 2, 2); if (type == ArmorType.Body) { this.imgHeight = 3; } this.armorRating = armorRating; this.type = type; this.extraLines = 3; } protected Armor(final Armor o, final int x, final int y, final int z) { super(o, x, y, z); this.armorRating = o.armorRating; this.type = o.type; } @Override public Armor copy(final Point newLoc) { return new Armor(this, newLoc.x, newLoc.y, 0); } public int getArmorRating() { return this.armorRating; } public ArmorType getType() { return this.type; } @Override public void addInfo(final Graphics g, final int x, final int y, final int width, final Font f, final FontMetrics m) { g.drawString("Armor - " + this.type.name(), x + (width - m.stringWidth("Armor - " + this.type.name())) / 2, y + 2 * m.getHeight()); g.drawString("Armor Rating: " + this.armorRating, x + (width - m.stringWidth("Armor Rating: " + this.armorRating)) / 2, y + 4 * m.getHeight()); } public enum ArmorType { Head("Head", 0), Hands("Hands", 1), Body("Body", 2), Feet("Feet", 3); private ArmorType(final String s, final int n) { } } }