import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map.Entry; import java.util.Set; /** * Lab 8 * * Class that simulates a battle arena for superheroes. * The user can print out information about all the superheroes, or can pit * two heroes against each other to see who would win. Victories are determined * by what superpowers the heros have and how the strengths/weaknesses match up. * * @author Stephen * @version 2017-10-07 */ public class HeroArena { /** * Maps short strings (abbreviations) to members of the Superhero enumeration. * We use LinkedHashMap to preserve ordering of inputs, which HashMap does * not do by default. */ private LinkedHashMap heroMap; /** * Constructor: Creates a predetermined set of heroes. We choose to create * one hero for each entry in the Superhero enum. * The abbreviations should be: * -"BAT": batman * -"SUP": superman * -"MAR": martian_manhunter * -"FLS": flash */ public HeroArena() { // Initialize the Hero HashMap: // TODO: implement // Populate the Hero HashMap // TODO: implement } /** * Attempt to get a hero from heroMap by using the abbreviated superhero name. * * @param key The abbreviation for the superhero in the heromap. * @return The superhero affiliated with the abbreviated name if the key exists in the heromap. * Null otherwise. */ public Superhero getHero(String key) { // TODO: implement } /** * Gets the abbreviated names of the superheroes. * * @return the abbreviations for the superheroes (keyset of heroMap), space separated. */ public Set getHeroAbbreviations() return heroMap.keySet(); } /** * Print out a Hero's three-letter abbreviation and the Hero's description for all heroes. * * @return The list of heroes as a string. Order is consitent across calls. * Format is: " - ", using a new line after each entry. */ public String listHeroes() { // TODO: implement } /** * Battles two heroes against each other. A victor is determined by superpower type advantages. Specifically, * if HeroA's superpower type is strong against HeroB's superpower type, HeroA will win the battle. * If the superpowers are the same type, the battle will end in a tie. * * We can assume that if type A is strong against type B, then type B is weak against type A. * We can also assume that type A and type B cannot be strong against each other. * * @param heroA The first hero in the battle. * @param heroB The second hero in the battle. * @return The hero that wins the battle, null if the heroes tie. */ public static Superhero battleHeroes(Superhero heroA, Superhero heroB) { // TODO: implement } }