public class Kata{ public static String multiply(String input,int times){ for (int i = 1; i < times; i++) {input += input.substring(0, input.length() / i);} return times!=0? input: ""; } }
- public class Kata{
- public static String multiply(String input,int times){
String save = input;for (int i = 1; i < times; i++) {System.out.println(input);input += save;}if(times == 0){input = "";}return input;- for (int i = 1; i < times; i++) {input += input.substring(0, input.length() / i);}
- return times!=0? input: "";
- }
- }
import org.junit.Test; import static org.junit.Assert.assertEquals; import org.junit.runners.JUnit4; // TODO: Replace examples and use TDD development by writing your own tests public class SolutionTest { @Test public void testSomething() { assertEquals("lsadfkjlsadfkjlsadfkj",Kata.multiply("lsadfkj",3)); assertEquals("hellohellohellohello",Kata.multiply("hello",4)); assertEquals("freefreefreefreefreefreefree", Kata.multiply("free",7)); assertEquals("",Kata.multiply("hu",0)); } }
- import org.junit.Test;
- import static org.junit.Assert.assertEquals;
- import org.junit.runners.JUnit4;
- // TODO: Replace examples and use TDD development by writing your own tests
- public class SolutionTest {
- @Test
- public void testSomething() {
- assertEquals("lsadfkjlsadfkjlsadfkj",Kata.multiply("lsadfkj",3));
- assertEquals("hellohellohellohello",Kata.multiply("hello",4));
- assertEquals("freefreefreefreefreefreefree", Kata.multiply("free",7));
- assertEquals("",Kata.multiply("hu",0));
- }
- }