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

public class StringMethodsPracSol f /* returns the index of the first Roman Nume

ID: 3727484 • Letter: P

Question

public class StringMethodsPracSol f /* returns the index of the first Roman Numeral in c or -1 *if c contains no Roman Numerals public static int indexOfFirstRomanNumeral(String s) t return -1; /returns the index of the first occurrence of a roman numeral in s starting from index startPosition or -1 if method overLoading public static int indexOfFirstRomanNumeral(String c, int startPosition) { return -1; /returns the index of the last occurrence of a roman numeral in k c or -1 if c contains no roman numerals / public static int indexOfLastRomanNumeral(String s) return -1; /*returns true if the first, last, and middle letter of c is the k same ignoring case or false otherwise. k Returns false if c is shorter than 3 characters The word wipes, it's simple what the middle letter is. What would it mean to be the middle letter for a word with an even number of letters?) public static boolean sameFirstLastMiddle(String c) t return true; /* returns a in reverse. For example, if a is "Lions", the method returns the String "snoiL" / public static String reversed (String a) return "; /returns the number of times that n occurs in a. For example, if a is "Mississippi" and b is "ss" * the method returns 2./ public static int numOccurrences (String a, String b) return-1;

Explanation / Answer

import static org.junit.Assert.assertEquals;

import org.junit.Test;

public class JunitTestCase {

@Test

public void testStringMethodPracSol(){

StringMethodPracSol myUnit = new StringMethodPracSol();

int result = myUnit.indexOfFirstRomanNumeral("indexOfFirstRomanNumeral");

assertEquals(-1, result);

  

result = myUnit.indexOfFirstRomanNumeral("indexOfFirstRomanNumeral",1);

assertEquals(-1, result);

  

result = myUnit.indexOfLastRomanNumeral("indexOfLastRomanNumeral");

assertEquals(-1, result);

  

boolean result1 = myUnit.sameFirstLastMiddle("sameFirstLastMiddle");

assertEquals(-1, result1);

  

String result2 = myUnit.reverse(" ");

assertEquals(" ", result2);

  

result = myUnit.numOccurence("numOccurence1","numOccurence2");

assertEquals(-1, result);

  

boolean result4 = myUnit.sameInReverse("sameInReverse");

assertEquals("false", result4);

  

String result6 = myUnit.deRomaned("deRomaned");

assertEquals(" ", result6);

  

String result9 = myUnit.appendedIfMissed("appendedIfMissed1","appendedIfMissed2");

assertEquals(" ", result9);

  

result = myUnit.indexOfAny("indexOfAny1","indexOfAny2");

assertEquals(-1, result);

}

}