This file goal is to help you complete thos project by splitting the task into doable "chunks". Complete these chunks in order.
Using Test Driven Development, create an Expression class that will break down a simple 2-term calculator expression.
- Prove you can extract the terms of the expression.
- Prove you can extract the operation embedded in the expression.
- Ensure you have examples of GOOD and BAD input and have your Expression class throw an exception when there's an error.
- Your expression should work with and without spaces. (i.e. both
2+1
and2 + 1
should work) - The use of Regular Expressions is not required.
- GOOD input example:
1+2
- BAD input example
+2
- You do not need to handle the cases of usage of parenthesis or expressions with more than 2 terms.
Using Test Driven Development, create another class (the name is up to you, but must be separate from the class int he first Chuch) that can evaluate a simple 2-term calculator expression, returning the appropriate answer.
- Prove your class can execute the correct operation of a GOOD expression. (If you already have classes for the various math operations, this is easy).
- Prove your class can handle a BAD expression.
- Should my Evaluate class print something to the Console? No
Using Test Driven Development, create a Stack class that can hold the last evaluated expression (for lastq
) and the last answer returned (for last
). Also, modify your class from chunk 2 to appropriatly handle the last
and lastq
commands.
- Ensure your Stack class can easily set the
lastq
andlast
(you can name your properties whatever you want) - Prove your class from Chunk 2 can properly handle the
lastq
andlast
commands.
Using Test Driven Development, expand your Stack class to handle the storage and retreival of Constants.
- Prove that any lowercase letter of the alphabet can be a constant. (e.g. 'a' or 'x'). Constant names are case insensitive.
- Prove that your constants can only be defined once per session. Throw an exception otherwise.
- Prove you can defined constants can be used in math expressions.
- Prove that undefined constants can not be used and doing so throws an exception.
- Constants are have names that are 1 character in size, (e.g.
a
orj
and neverabc
) - 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. ;)