Move History

Fork Selected
  • 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 {
        @Test
        void returnsZeroForEmptyString() {
            int result = StringCalculator.add("");
            assertEquals(0, result);
        }
    }