A simple seven-digit calculator representation using ASCII characters printed out in the terminal. Controlled using a keyboard's arrow and enter keys. Code is organized into header files and is documented with comments.
This program makes use of Microsoft's conio.h library to take keyboard input without printing it to the terminal (credit to Erik Anderson on Stack Overflow). It is therefore unable to function on any non-Microsoft OS devices.
Because of the nature of output in the code, messy text can be fixed by resizing the window to fit the entire calculator and pressing the CLEAR button in the botton right corner.
This C++ project has two main moving parts: an adjacency list of buttons that can be pressed, and the calculator that keeps track of the numbers and operations that are given to it. All printing is done through the output.h file, which uses ANSI Escape Codes extensively.
As seen in the image above, the OFF button is highlighted in red, while the rest of the calculator is white. This is all kept track of in the buttons.h header file, which keeps an adjacency list of button objects.
Each button on the calculator has a corresponding character value, an (x, y) coordinate system, a string array to help in output, and a list of the button's neighbors on the calculator.
The buttons.h file keeps track of a head value, which is the highlighted button. When an arrow key is pressed, the head moves one node in the direction of the arrow key pressed. The output then resets the color of the previous button and updates the new button to be red.
As with any calculator, in order to function, this project must be able to keep track of a set of numbers, and perform operations such as addition or multiplication on one another. This information is kept in the calc.h header file, which updates information when a user presses the ENTER key with any button selected.
The system of calculation consists of two decimal numbers and an operation. The user may type in two numbers separated by an operation (+, -, *, /), and the result is put back into the first number. This way, multiple calculations can make use of previous operations.
