Question: Link to question: http://codecheck.it/files?repo=fall2017&problem=q2 So I found the answer to this question, but I'm not sure how the tester file for this would look. So

Link to question: http://codecheck.it/files?repo=fall2017&problem=q2

So I found the answer to this question, but I'm not sure how the tester file for this would look. So here is the Strings.uniqueLetters(String str) method which is the answer:

public class Strings

{

public static String uniqueLetters(String str)

{

String ret = "";

for(int i = 0; i < str.length(); ++i) {

boolean found = false;

for(int j = 0; j < str.length(); ++j) {

if(i != j && str.charAt(i) == str.charAt(j)) {

found = true;

}

}

if(!found) {

ret += str.charAt(i);

}

}

return ret;

}

}

But I'm having trouble writing the testing file. How would I test this in eclipse? I am converting to Java from C++ and I am quite confused. This is what I have so far:

public class Tester

{

public static void main(String[] args)

{

String str = "bananas";

Strings.uniqueLetters(str);

System.out.println(Strings.toString(str));

System.out.println("Expected: bs");

}

}

Please tell me how the testing program should look like. Thank you!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!