Break my calculator please

It’s not going to win any awards for “purdy” but I’m happy with the functionality.

Comments? Criticism?

1 Like

Works great! Couldn’t find any bugs and the parentheses are nice to have

Decimal point functionality is buggy. Should refuse input after the first one. Similarly with brackets that are clearly wrong (e.g. if you start with a closing bracket).

I won’t know if that is a “but” per se - an unintentional error that causes a crash or an erroneous result. It was a design choice. I chose to handle that by giving an “error” message when it is evaluated. But I guess that is how most calculators work - perhaps I’ll go back and add that in.

Fair enough. I have a background in UX testing though, so I always approach problems from the point of view of “what is the user most likely to want?” In this case, it’s more likely that it was an accidental button press (unless the user doesn’t understand some pretty fundamental things about math).

Still, overall this is a good solution, keep at it! :smile:

You’re right, I probably didn’t make the best design choice. It’s just that ages ago when I studied programming (when dinosaurs roamed the Earth) a professor always made a distinction between a bug and bad design choice.

But I agree that your suggestion would make it better. It seems like it would be an easy fix. I

OK, I’ve added in some logic to answer lionel’s advice:

  1. It won’t allow a decimal point if one is already in the current number.
  2. It’s smarter about parentheses - it won’t allow an open unless it’s the first sign or preceded by a non-num and won’t allow a close parenthesis unless there is a matching open and the preceding element must be a number.
  3. It won’t allow two arithmetic operators in a row.

Thanks for the advice. Someone else try to break it, please.

Regards,
Kevin