java-algorithms-implementation
java-algorithms-implementation copied to clipboard
Fixed #167. Refactor: centralized type handling for simple operations such as add and subtract, and added branch coverage for this
Created functions which take two Number objects, and either adds, subtracts, or compares them. These Number objects can be of type Integer, Long, Float, Double, BigInteger or BigDecimal. Also added function which does row multiplication for Number arrays.
Instead of using the same code spread over multiple functions, this patch centralizes it to one class (Operations.java), thus decreasing code repetition and cylcomatic complexity, while increasing readability.
Also added branch coverage for these different Number types, since it was missing (previous tests only tested relevant functions using Integers).
For more details, see issue #167.
By submitting this pull request I confirm I've read and complied with the below requirements.
- [x] I have read the Contribution guidelines and I am confident that my PR reflects them.
- [x] I have followed the coding guidelines for this project.
- [x] My code follows the skeleton code structure.
- [x] This pull request has a descriptive title. For example,
Added {Algorithm/DS name} [{Language}], notUpdate README.mdorAdded new code.