Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Enum Direction java.lang.Object java.lang.Enum edu.ccave.common.Direction All Im

ID: 3875021 • Letter: E

Question

Enum Direction

java.lang.Object

java.lang.Enum

edu.ccave.common.Direction

All Implemented Interfaces:

java.io.Serializable, java.lang.Comparable

All possible directions that a player can travel. We read a properties file to determine the synonyms for each direction. This enum reads a properties file for each enum value in the resources directory, such as

n.properties

s.properties

etc.

The keys of these properties files don't really matter--the values do. So for Direction.N, in n.properties

n=north

n1=othernorthvalue

n2=anothernorthvalue

will all define synonym String values for Direction.N.

Enum Constant Summary

Field Summary

Method Summary

enum-wide method to provide a more friendly valueOf method.

Determine whether a given String value represents this Direction value ignoring case, or one of its synonyms ignoring case.

Returns the enum constant of this type with the specified name.

Returns an array containing the constants of this enum type, in the order they are declared.

Methods inherited from class java.lang.Enum

compareTo, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf

Methods inherited from class java.lang.Object

getClass, notify, notifyAll, wait, wait, wait

Enum Constant Detail

N

S

E

W

NE

NW

SE

SW

UP

DOWN

UNKNOWN

Field Detail

RESOURCE_DIR

See Also:

Constant Field Values

Method Detail

values

Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:

Returns:

an array containing the constants of this enum type, in the order they are declared

valueOf

Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:

name - the name of the enum constant to be returned.

Returns:

the enum constant with the specified name

Throws:

java.lang.IllegalArgumentException - if this enum type has no constant with the specified name

java.lang.NullPointerException - if the argument is null

findSynonym

enum-wide method to provide a more friendly valueOf method. We take a String representation of an enum value or synonym and, ignoring case, return the corresponding Direction enum value. This method steps through every possible enum value, which it can do using values(). It then tests whether possibleAlt matches one of those values. (See isSynonym)

Parameters:

possibleAlt - String representing a case-insensitive, synonym-based Direction value

Returns:

the Direction value associated with possibleAlt, or Direction.UNKNOWN

isSynonym

Determine whether a given String value represents this Direction value ignoring case, or one of its synonyms ignoring case.

Parameters:

possibleAlt - a possible String representation of this Direction or one of its synonym values

Returns:

true if possibleAlt is a valid String value for this Direction or one of its synonyms, all ignoring case

Skip navigation links

Overview

Package

Class

Use

Tree

Deprecated

Index

Help

Prev Class

Next Class

Frames

No Frames

All Classes

Summary:

Nested |

Enum Constants |

Field |

Method

Detail:

Enum Constants |

Field |

Method

You may add other synonyms as you wish.

3: The Direction enum has an instance variable of type ArrayList that holds the enum's given synonyms from the corresponding properties file information.

4: The Direction enum's constructor reads the associated properties file from the resources directory and adds the synonyms to the ArrayList instance variable.

5: The attached zip file contains Javadoc pages describing the details of Direction in greater detail, and also describes a minimal tester. Unzip it and use a browser to open index.html in the directory structure.

Enum Constants Enum Constant and Description DOWN E N NE NW S SE SW UNKNOWN UP W

Explanation / Answer

1. The zip file containing Javadoc pages describing the details of Direction in detail and a minimal tester is unavailable.

2. Kindly state your question clearly. The question mentions only a bunch of enums, methods etc. But what is the question?