Hi there,
I don't know, perhaps is because my english is a bit rusty but to me the way this task is worded leads to confusion.
These are the conditions of the taks:
*************************************************************************
StringHelper class
In the StringHelper class, implement two static methods:
String multiply(String s, int count) - returns a string that has been repeated count times
String multiply(String s) - returns a string that has been repeated 5 times
Example:
Amigo -> AmigoAmigoAmigoAmigoAmigo
Requirements:
1. The StringHelper class's methods must return a string.
2. The StringHelper class's methods must be static.
3. The StringHelper class's methods must be public.
4. The multiply(String s, int count) method must return a string that has been repeated count times.
5. The multiply(String s) method must return a string that has been repeated 5 times.
****************************************************************************************************
To me, methods arguments were already the repeated string and the task was to find the original word (without repetitions).
Also there's a mismatch between the task before being solved and the solutions given by the platform.
This is the task before being solved:
package en.codegym.task.jdk13.task06.task0611;
/*
StringHelper class
*/
public class StringHelper {
public static String multiply(String text) {
String result = "";
//write your code here
return result;
}
public static String multiply(String text, int count) {
String result = "";
//write your code here
return result;
}
public static void main(String[] args) {
}
}
This is the solution given by CODEGYM:
package en.codegym.task.jdk13.task06.task0611;
/*
StringHelper class
*/
public class StringHelper {
public static String multiply(String text) {
return multiply(text, 5);
}
public static String multiply(String text, int count) {
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < count; i++) {
stringBuilder.append(text);
}
return stringBuilder.toString();
}
public static void main(String[] args) {
}
}
As you can see the vars result that are in the proposal and that are placed before the signal "//write your code here", are missing in the solution.
Thanks