Question
In Python 3 String Calculator Create a simple StringCalculator class with a method that returns an integer called Add(string numbers) The method can take 0,
In Python 3
String Calculator
Create a simple StringCalculator class with a method that returns an integer called Add(string numbers)
The method can take 0, 1 or 2 numbers, and will return their sum (for an empty string it will return 0) for example or 1 or 1,2.
Start with the simplest test case of an empty string and move to 1 and two numbers
Remember to solve things as simply as possible so that you force yourself to write tests you did not think about
Remember to refactor after each passing test
Allow the Add method to handle an unknown amount of numbers
Calling Add with a negative number will throw an exception negatives not allowed - and the negative that was passed.if there are multiple negatives, show all of them in the exception message. There should be a test case that tests for the exception.
Numbers bigger than 1000 should be ignored, so adding 2 + 1001 = 2
Remember that your input is one string containing 1 or more numbers separated by commas.
You will need a minimum of 4 test cases.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started