The goal of this project is to create two functions: Converter.toUnsignedInt() and Calculator.sum(). The development for these two functions will be done with TDD.
This function will take in a string that contains only not letters or special characters. Assume the frontend will limit the available input through a standard number input keyboard seen on the right in the below image.
- Input will limited on the front-end to contain only the following characters:
0,1,2,3,4,5,6,7,8,9,_,-,, - A unique exception should be thrown when the input contains a decimal (
.) - A unique exception should be thrown when the input contains a dash (
-) - A unique exception should be thrown when the input contains a underscore (
_) - A unique exception should be thrown when the input contains a comma (
,) - A unique exception should be thrown when the input is longer than 3 digits
Should compute the sum of an array of numbers, each represented in a string.
- When there are no inputs, return
0sum([]) = 0
- When there is one input, return that number
sum(["2"]) = 2sum(["17"]) = 17
- When there are two or more inputs, return the sum
sum(["1", "5"]) = 6sum(["20", "3", "8"]) = 31
- If any exception occurs, throw a
CalculationExceptionsum(["-1", "3", "8"]) = !!CalculationExceptionsum(["4", ".25", "9"]) = !!CalculationExceptionsum(["_", "7"]) = !!CalculationExceptionsum([","]) = !!CalculationExceptionsum(["20", "3", "9108"]) = !!CalculationException
