Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

/** * Selector that returns false if the current string is * within a javadoc co

ID: 3710736 • Letter: #

Question

/**

* Selector that returns false if the current string is

* within a javadoc comment, true otherwise. Using a NonJavadocSelector

* in the filter method of a StringList has the effect of removing all

* javadoc comments. Note that we are assuming that javadoc comments

* always start and end on different lines, and that no executable

* code ever appears on the same line as a javadoc comment.

*/

public class NonJavadocSelector implements Selector

{

@Override

public boolean select(String s) {

return null;

}

}

Explanation / Answer

Below is your code: -

/**

* Selector that returns false if the current string is within a javadoc

* comment, true otherwise. Using a NonJavadocSelector in the filter method of a

* StringList has the effect of removing all javadoc comments. Note that we are

* assuming that javadoc comments always start and end on different lines, and

* that no executable code ever appears on the same line as a javadoc comment.

*/

public class NonJavadocSelector implements Selector {

// Assuming a string in this case is a line

public boolean select(String line) {

if (line.length() < 2) {

return true;

}

if (line.charAt(0) == '*' && line.charAt(1) == ' ') {

return false;

}

if (line.equals("/**") || line.equals("/** ")) {

return false;

}

if (line.equals("*/") || line.equals("*/ ")) {

return false;

}

return true;

}

}