-
Description This is a practice with XsstentialCrisis team.
Step 1 Create a simple String calculator with a method signature:
int Add(string numbers)
The method can take up to two numbers, separated by commas, and will return their sum.
For example “” or “1” or “1,2” as inputs.
For an empty string it will return 0.
Code public class StringCalculator{ public static int add(String numbers){ return -1; } }
Test Cases Failed import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; // TODO: Replace examples and use TDD by writing your own tests class StringCalculatorTest { void returnsZeroForEmptyString() { int result = StringCalculator.add(""); assertEquals(0, result); } }
Output:
-
- All
- {{group.name}} ({{group.count}})
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}