LemaireEmilien / calculator-cucumber-2024

This repository is used for teaching purposes at the University of Mons. It contains Java code for computing arithmetic expressions. The code uses design patterns and is accompanied with JavaDoc, unit tests and BDD scenarios. We have also paid particular attention to code quality.
0 stars 0 forks source link

Boolean logic #25

Closed Faltmatix closed 5 months ago

Faltmatix commented 5 months ago

Added support for boolean logic

The truth atoms are "true" and "false". They make use of MyNumber and evaluate respectively to 1 and 0. The operators (ordered by precedence) are:

Many tests were made to ensure correct evaluation and precedence order of boolean expressions. Here are some examples of strings and their evaluations:

  | expr                            | result |
  | !true                           | 0      |
  | !false                          | 1      |
  | true & false                    | 0      |
  | !(true & false) ^ true => false | 1      |
  | (true & false) \| true => true  | 1      |

Notable changes

I used the "^" symbol for XOR operations. It was in conflict with the exponentiation. I replaced the exponentiation symbol by "**" to keep it available.

GUI

I did not add anything to the GUI as it has already quite a few buttons. But everything can be typed and evaluated inside the calculator GUI.

github-actions[bot] commented 5 months ago

Test Coverage Summary