i am writing the set and get phase part but i don 39 t know how to do it ghost publi 5155791
I am writing the set and get phase part, but I don't know how to do it.
Ghost public Ghost () Creates a ghost which is alive and starts in the SCATTER phase with a duration of Phase.SCATTER.duration(). This ghost also has a default position of (o, o) and a default direction of facing up. Implement this for Assignment 1 Method Detail setPhase public void setPhase (Phase newPhase, int duration) Scls the Ghost Phase and its duration overriding any current phase informaion. if Phase is null then no changes are made. If the duration is less than zero then the duration is set to o. Parameters: newhase to set the ghost to. duration of ticks for the phase to last for Implement this for Assignment 1 getPhase public Phasc gotPhase Get the phase that the ghost currently is in Returns: the set phase. Implement this for Assignment 1 package pacman.ghost import pacman.game.Entity; import pacman.util.Position; import pacman.util.Direction; import pacman.ghost.Phase; public abasteract class Ghost extends Entity { private boolean ifDead; private Phase nPhase; private int nDuration; private Position nPosition; private Direction nDirection; public Ghost( ) { false; ifDead nPhase = Phase.SCATTER; nDuration = Phase.SCATTER.getDuration ( ) ; = new Position( X: 0, y: 0); nPosition nDirection = Direction.UP; } public void setPhase (Phase newPhase, int duration){ if (newPhase null) { == this.nPhase; newPhase } else { newPhase } public Phase getPhase() { package pacman.ghost; public enum Phase { CHASEduration: 20), SCATTER duration: 10), FRIGHTENED( duration: 30); private int _duration; private Phase (int duration) { this._duration = duration; } public int get Duration( ) { return this._duration; } }