Multiplying Integers
Interpreters, Iteration 6
User Story
Your client interrupts you with this story. You figure it should be easy enough to add now (before you deal with adding strings).
User Story #6: Interpreter evaluates a two-value product.
A Hobbes program can be the multiplication of two integers.
Example: 2 * 3
evaluates to 6
.
Some languages allow "a" * 4
which results in
"aaaa"
. I'm sure if your client wants this, you'll be
told.
On Your Own
This is an iteration you'll do on your own. Here are some things to consider:
- There is an
OperatorETIR.Operator.MULTIPLY
. - Write some great tests.
- Don't be afraid to duplicate some code. Don't duplicate too much code
- Try to remove smells
- Are your variable and method names honest and accurate? If not, try a rename refactoring.
- Is a method getting too long (i.e., more than five lines of code)? Try an extract-method refactoring.
- Try multiple solutions.