Enum Class DiceType

Object
Enum<DiceType>
DiceType
All Implemented Interfaces:
Serializable, Comparable<DiceType>, Constable

public enum DiceType extends Enum<DiceType>
Enumeration representing different types of dice. Ranges from D4 to D20.

Keep the enum simple. Javadoc automatically generates methods that are created behind the scenes

NOTE: the enum type will automatically add the following methods:
  • static DiceType valueOf(java.lang.String name)
  • static DiceType[] values()
Even though they show up in the javadoc, you don't need to implement them.

Enum Creation

As a reminder, enums are relatively simple to create. Don't let the javadoc fool you. Below is all you need in the DiceType.java file (including the code you need to replace in the comment)

 
  public enum DiceType {
      // TODO: your enum constants here
  }
 
  • Enum Constant Details

    • D4

      public static final DiceType D4
      a 4 sided die
    • D6

      public static final DiceType D6
      a 6 sided die
    • D8

      public static final DiceType D8
      a 8 sided die
    • D10

      public static final DiceType D10
      a 10 sided die
    • D12

      public static final DiceType D12
      a 12 sided die
    • D20

      public static final DiceType D20
      a 20 sided die
  • Method Details

    • values

      public static DiceType[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static DiceType valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null