Data Type Option Pane


Data Type Option Pane image

Goal:

Create a new enum and populate a JOptionPane with a selection of choices for use with a switch statement.

Steps:

  1. Create a new enum called DataType. The entries should be the primitive data types listed here.
  2. Give the enum a member variable called bits.
  3. Set each entry's default value to the number of bits it can hold.
  4. Create a constructor to initialize bits and a getter to access bits.
  5. Initialize the dataTypes array to have one of each unique value using the .values() method.
  6. Create a JOptionePane Option Dialog that asks the user to select the data type they want to learn about. Use the dataTypes array for the options parameter and save the result into an int.
  7. Create a switch statement that switches on the dataTypes enum array at the result of the Option dialog. For each value in the data type enum, create a case with a Message Dialog that tells the user what kinds of values the type can contain and use the getter to display how many bits it is made up of.