Skip to content

Instantly share code, notes, and snippets.

@jcockhren
Last active October 20, 2015 01:16
Show Gist options
  • Save jcockhren/6f81dfe974155b385c5f to your computer and use it in GitHub Desktop.
Save jcockhren/6f81dfe974155b385c5f to your computer and use it in GitHub Desktop.
Simple Calculator chunk 4 - Constants

Simple Calculator chunk 4 - Constants

Goal

Using Test Driven Development, expand your Stack class to handle the storage and retreival of constants.

  1. Prove that any lowercase letter of the alphabet can be a constant. (e.g. 'a' or 'x'). Constant names are case insensitive.
  2. Prove that your constants can only be defined once per session. Throw an exception otherwise.
  3. Prove you can defined constants can be used in math expressions.
  4. Prove that undefined constants can not be used and doing so throws an exception.

Hint

  • You can create a class Constants if you want, but it is not required. If you choose to create another class, the class must be unit tested.
  • Your Stack class should use the Constants class. ;)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment