Calculator App

Overview

This calculator is an implementation by Wade Wooldridge using the following technologies:

  • HTML: for the basic page layout
  • CSS: for styling and reveling the cards
  • Bootstrap: for the basic page grid layout
  • JavaScript: for object-oriented state machine

Features

This calculator supports the following features:

  • Button or keyboard input.
  • Expanded displays for accumulator and implied value (can be disabled in hamburger menu).
  • Scrolling history log of operations in panel-footer (can be enabled in hamburger menu).
  • Built-in Self-Test capability that is executed on startup, or through the hambuger menu.
  • Animated button pushing on Self-Test when executed through the hamburger menu.
  • Basic addition, subtraction, multiplication, division.
  • Decimal support, with some allowances for JavaScript decimal rounding errors.
  • Clear and Clear Entry functionality.
  • Operator repeat, operator override, operator rollover.

Program Notes

  • The calculator was intended as an exercise in Object-Oriented Programming. It is broken into the following objects:
    • Calculator: for the view into the calculator.
    • Processor: for the unit that keeps context and does the math.
    • Tester: contains an array of test input and expected outputs. This is used by the Processor during initialization, and by the Calculator object for the animated self-test with button pushes (available through the hamburger menu.
  • Though not strictly necessary for calculator operation, the interface displays the current main display value, plus the currently-selected operator, plus the "accumulator" and "implied" fields from the current context.
  • The calculator starts by executing a selfTest() function that takes it through each of the specified sequences from the requirements. This allows for simple testing of all functionality to make sure new changes do not break the existing functionality. Any failure in selfTest will result in the calculator starting with a display of "POST Error". In such a case, the calculator can be cleared and will continue to operate.
by Wade Wooldridge