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
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 oppositesStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started