[solved]-Class Map Map Represents Spots Things Simulation Provides Support Methods Well Likely Need Q39034983
class Map
A Map represents all the spots and things in a simulation, andprovides some support methods for them as well. You will likelyneed to create the enumerations, interfaces, and many of theThingclasses before you can pull them all together with the Mapclass.
Fields
- protected Spot[][] floorplan
- protected Thing[] things
- protected java.io.PrintStream log
Methods
- Map(String filename, PrintStream log). Readsthe given file to construct a map and all spots/things on it. Anymessages (such as safety or death messages) from this map will besent to log.
- any “map file” that is named in the first argument (“Stringfilename”) is assumed to have the same number of characters in eachline, each line ends with a “n” character, and each character isassumed to be one of our valid characters (see MapRepresentations). If any of these assumptions is invalidated, orthe file doesn’t even exist, your program does not need to function(behavior is undefined). You may add throws IOException to yourmethod signature as necessary.
- Manual Inspection Criteria (5%) : Welldocumented, elegant solution to reading the map text files. (Seemore details in the grading section of this projectspecification).
- public boolean onMap(Coord c). Answers if thegiven Coord is on this Map.
- public Spot spotAt(Coord c). Returns the Spotat the given Coord, if present (from the floorplan). If the Coordisn’t on the map, this method will return null.
- public int peopleRemaining(). Returns how manypeople are still trying to escape. Status.Safe and Status.Deadpeople don’t count, but Status.Escaping people do get counted.Threats don’t count either, of course.
- public void addThing(Thing a). Occasionallynew things should be added (usually these are threats that havespawned more spots of sticky or smoke). Accept a new Thing (assumedto be on the map), and cause the things field to be one spotlonger, with this new one at the end. Remember, arrays can’t changelength. How will you get around this? (you can’t change the type ofthe field)
- Manual Inspection Criteria (5%) :well-documented description of your approach to dealing withgrowing arrays (and a matching implementation).
- public Thing[] thingsAt(Coord c). Return anarray of all Thing values found at the given coordinate. Preservethe order of original appearance. If c isn’t on the map, or noThing is there, an empty array is returned.
- public boolean canLookThroughLocation(Coordc). Considering the spot and all things on that spot, cana person look through this location? If c isn’t on the map, falseis returned.
- public boolean canPassThroughLocation(Coordc). Considering the spots and all things on that spot, cana person pass through this location? If c isn’t on the map, falseis returned.
- public void iterate(). For all Thing items wesaw in their original order of discovery/spawning, allow them toperform an action by calling their doAction() method. This mayalter the map by changing Thing positions or adding new Things.
- after allowing all things to make their moves, the message”map:” must be sent to log, and then this map’s toString()representation must also be sent to the log.
- if a StickyIcky is spawned into a spot containing people, itimmediately kills them; it doesn’t need to wait for the nextiteration. Note, this doesn’t count as taking an action (do notcall doAction on the spawned threat).
- @Override public String toString(). Returns aString that represents one entity per location. When more than onething exists at a location, here is the order of preference (higherin the list is chosen):
- Wall
- Smoke
- StickyIcky
- any Person (prefer the last in the map’sthings array)
- Exit, Open, or Sign spots (any direction)
Tester: https://paste.ee/p/U95ng
Thing: https://paste.ee/p/Wd8h0
FloorPlan : https://paste.ee/p/b8jPl
Coord: https://paste.ee/p/UnsnC
Thanks
Expert Answer
Answer to class Map A Map represents all the spots and things in a simulation, and provides some support methods for them as well…. . . .
OR

