Before you start:
Try not to read ahead and do one task at a time.
Create a simple String calculator with a method int Add(string numbers).
The method can take a string representing numbers separated by commas, and will return their sum (for an empty string it will return 0) for example “” or “1” or “1,2”.
- Start with the simplest case of an empty string and move to 1 and 2 numbers.
- Allow the Add method to handle an unknown amount of numbers.
- Allow the Add method to handle new lines between numbers (as well as commas). a. The following input is ok: “1\n2,3” (will equal 6). b. The following input is NOT ok: “1,\n”.
- Support different single character delimiters (case-insensitive). a. To change a delimiter, the beginning of the string will contain a separate line that looks like this: “//[delimiter]\n[numbers…]” for example “//;\n1;2” should return three where the delimiter is ‘;’.
- Calling Add with a negative number will throw an exception “Negatives not allowed” - and the negative that was passed in. If there are multiple negatives, show all of them in the exception message.
- Numbers greater than 1000 should be ignored, so adding 2 + 1001 + 13 = 15.
- Allow multiple delimiters like this: “//[delim1][delim2]\n” for example “//%\n12%3” should return 6