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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started