Question: Java: Please help with creating enumerations in this program about Panic. This project is called Panic! We will describe a single-level floorplan of a building,
Java: Please help with creating enumerations in this program about Panic. This project is called Panic! We will describe a single-level floorplan of a building, filled with different kinds of people and different kinds of threats. We will simulate how the people seek to evacuate the building to safety, and how the threats spread throughout the building. Various events will be announced, such as person movements, threats spawning, and people reaching safety or succumbing to the threats. We will read a map representation from a file, and we will write the messages to either a file or just System.out as directed.
enum Status
We have people moving around on our Map, so we want to know what their status is. People will start as Escaping, and either become Safe or Dead. I hope you are able to save them!
Values
Escaping, Safe, Dead.
There are no special methods to create.
enum Direction
People are always facing certain directions. Signs that point out where an exit is will also have a direction as part of their representation.
Values
N, E, S, W, and none.
Methods
public Direction cycle(). Given a Direction, cycle around to the next direction in clockwise fashion: N ? E, E ? S, S ? W, W ? N, none ? none.
public Direction getOpposite(). Given a Direction, report back the opposite direction. N / S report each other, E / W report each other, and none reports itself.
public boolean isOpposite(Direction other). reports if the given direction is opposite of the other. none is never opposite anything else, but N / S are opposites and E / W are opposites.
Manual Inspection Criteria Reminder
you need to use the methods, such as cycle and getOpposite, where appropriate. Don't re-implement their behavior anywhere else.
enum Spot implements Representable, Passable
enum Spot implements Representable and Passable interfaces. (what methods will Spot have to implement as a consequence?) Spots represent the permanent walls, spaces, and signage at a particular coordinate on a Map. Other things may be also present at a coordinate or not during the simulation, but the Spot is the actual wall, open spot, exit (also open in a sense), or sign (an open spot with an exit sign).
Values
Open, Wall, Exit, SignN, SignE, SignS, SignW.
Fields
You can add whatever fields you'd like beyond String repr in order to complete the required methods. If you do, they must either be private or be public final. It may be useful to use the following: boolean lookThrough, boolean passThrough, Direction dir.
public final String repr. Representation of the spot. The correct characters must be used (see Map Representations).
Methods
Spot( ??? ). Constructor, intializes any fields you have. Luckily for testing purposes, we don't get to create extra values of your enumeration type, so it doesn't matter what exact signature your constructor has as long as the methods below are provided as expected.
Manual Inspection Criteria (5%) : your constructor correctly initializes any and all fields your Spot enumeration contains.
public boolean isSign(). Determines if the spot is one of our four SignX spot values.
@Override public String toString(). Uses the repr value as its result.
@Override public String repr(). Uses the repr value as its result.
@Override public boolean canLookThrough(). Answers if a person is able to look beyond this spot. It is true for all spots except Wall.
@Override public boolean canPassThrough(). Answers if a person is able to walk into/through this spot. It is true for all spots except Wall.
---Code for interface Passable (used to implement----
public interface Passable { public abstract boolean canLookThrough(); public abstract boolean canPassThrough(); }
-----Code for interface Representable (used to implement)---
public interface Representable {
public abstract String repr(); }
----------Tester for enumerations-------
https://paste.ee/p/o49s5
Thank you.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
