java abstract problems please help me with two abstract classes classthreat and clas 5122134
Java abstract problems: Please help me with two abstract classes (classThreat) and (class GreenSlime) im thisprogram called “Panic”. Here is the link to the introduction and some samples ofthis program: https://paste.ee/p/y2BqB. Required classes for implemented and extended are provided atthe bottom. ————————Here is thetask———————— class Threat public abstract class Threat extends Thing Threat is an abstract class that extends Thing. Threats are thebad things from which people are trying to escape. They spread(spawn) at regular intervals; we store how long it’s been since thelast spawning (via charge), and also at what point they will againspawn (via fullCharge). Manual Inspection Criteria (2%) : Threat housesmost of teh code related to increasing/resetting charge, andspawning potentially four children in four new locations. Childclasses only define the specifics of spawning and any specialadditional actions during doAction(). Fields protected int charge protected final int fullCharge Methods public Threat(Coord c, String repr, int fullCharge, Mapmap, PrintStream log). Initializes the fields. chargestarts at 0. public abstract void spawn(Coord c). Childclasses will provide an implementation that spawns (creates) a newthing identical to itself, but at the given clocation. During thespawn() method, a child places a copy of the new object on the mapand carries out any further actions such eliminating unfortunatehumans in their path. (do not call doAction here, only actions suchas a GreenSlime immediately killing present people will occur). @Override public void doAction(). First actionis to increment charge. If it reaches fullCharge, it’s time tospawn! When at full charge, take the following actions.Log amessage of the form g@(1,8) spreading which indicates the type and location of the threat that isspreading/spawning. (Hazes also can spread; ~@(1,8) spreading alsoappropriate). Call the spawn(c) with a Coord for all four cardinal directions(north, east, south, west) from the spawning threat. Only call spawn(c) if the spot canPassThrough() which is truefor non-wall spots. reset charge to zero.
Note: Threat doesn’t provide implementations for anymethods from Passable, so those are still the child classes’responsibilities. —– class GreenSlime public class GreenSlime extends Threat It has no fields, but has a constructor and overrides variousabstract methods it inherited, in order to be concrete. Methods public GreenSlime(Coord loc, Map map, PrintStreamlog). Via the parent constructor, sets all fields.fullcharge must always be 4, and the starting value for charge is0. @Override public void spawn(Coord c). Creates anew GreenSlime and adds it to the map at location c. The followingconsiderations should be made Do not spawn a new slime in a location that already has a greenslime. This will require checking that there is no slime at thecoordinate c. Generate a log message of the form g@(1,7) spawned where the location is the position of the new slime. Any Person at the new spawn location is eliminated. When killinghumans, call their die() method. Also generate a log message of thefollowing form g@(1,7) killed z@(1,7) @Override public void doAction(). After callingthe version of doAction inherited from Threat, this GreenSlimeobject will check what non-dead persons are present at its locationon the map, and kills them (calls their die() method). Sincemultiple people may be present, mulitple deaths may occur. Whenevera person is killed, a message must be sent to the log, utilizingtoString() definitions. Example: g@(4,5) killed a@(4,5) @Override public boolean canLookThrough().People can actually look through a spot containing a GreenSlime; itdoesn’t obscure the whole view like a Walldoes. @Override public boolean canPassThrough().Return true here. A Person can attempt to pass through a greenslime but it will result in death. Suggestion: In several places, GreenSlimes mustkill all humans at their location (during spawn() and doAction().This suggests a private method to kill all humans at the slime’slocation is useful. Such a method might help with part of themanual inspection criteria. ——–Java codes for class Thing, class Representable andclass Passible (used to extend)———- Please open the link, because they are a little long. Thankyou class Thing: https://paste.ee/p/j6ULE class Representable: public interface Representable { public abstract String repr(); } class Passible: public interface Passable {
public abstract boolean canLookThrough();
public abstract boolean canPassThrough(); } Class Coord (Coord.java) :https://paste.ee/p/pgUlM Here is the link to the overview of this program:https://paste.ee/p/LE1l0 Please read and help me, I would greatly appreciate yourhelps. . . .