Question: Create this enum in JAVA enum Direction People are always facing certain directions. Signs that point out where an exit is will also have a

Create this enum in JAVA

Create this enum in JAVA enum Direction People are always facing certain

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.

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, S, v, and none. Methods . public Direction cycle(). Given a Direction, cycle around to the next direction in clockwise fashion : N , s. s N, ncne none. public Direction get0ppositeO. Given a Direction report back the opposite direction. /s report each other, E/ report each other, and nons 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 / are opposites

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!