Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Seven Databases In Seven Weeks A Guide To Modern Databases And The NoSQL Movement

Authors: Luc Perkins, Eric Redmond, Jim Wilson

2nd Edition

1680502530, 978-1680502534

More Books

Students also viewed these Databases questions

Question

=+What is the big message you want them to know?

Answered: 1 week ago

Question

=+What do they (audience members) currently think?

Answered: 1 week ago