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

The following directory structure of Test driven development comp |-- lib |__ |-

ID: 665012 • Letter: T

Question

The following directory structure of Test driven development

comp

|-- lib

|__ |-- checkstyle-6.5-all.jar

|__ |-- hamcrest-core-1.3.jar

|__ -- junit-4.12.jar

|-- Makefile

|-- src

|__ -- PalindromeChecker.java

-- tests

|-- MyTestRunner.java

-- PalindromeCheckerTest.java

All of your file, class, and method names, if specified in this assignment, must have the exact names specified

The purpose of this assignment is to make you more familiar with recursion and test driven development. In PalindromeChecker.java you will find a method with the header:

public class PalindromeChecker {

public static boolean isPalindrome(String str) {

// your code goes here

This method should return true if str is a palindrome, and false otherwise. A palindrome is any word, phrase, or sentence that reads the same forward and backward. Here are some examples of palindromes:

• Able was I, ere I saw Elba

• A man, a plan, a canal, Panama

• Desserts, I stressed

• Kayak

Note from the examples above, you should ignore case, spaces, and punctuation. Your implementation of isPalindrome must be recursive. Furthermore, you must write your code using the test driven development methodology. You must write your tests in PalindromeCheckerTest.java

import static org.junit.Assert.assertFalse;

import static org.junit.Assert.assertTrue;

import static org.junit.Assert.fail;

import org.junit.Test;

public class PalindromeCheckerTest {

// your tests go here

You can check that:

1. your code builds with make build

2. your code pases your tests with make test

3. your code adheres to the Google java style with make checkstyle

If you simply run make then the above three things will be checked in order

Hese are good secondary measures of whether you

followed TDD:

•Your code passes the Checkstyle audit.

•Your code has an appropriate amount of commenting.

•You have an appropriate number of tests.

•Your code passes all your tests

•Your code is not overly complex.

•Your impementation of the required method is correct.

Explanation / Answer

import java.util.Scanner;
public class PalindromeChecker
{
    public static boolean IsPalindrome(String str)
    {
        if (str.length() == 0 || str.length() == 1 )
            return true;
        if (str.charAt(0) == str.charAt(str.length()-1))
            return IsPalindrome(str.substring(1,str.length()-1));
        return false;  
    }

     public static void main(String []args){
        System.out.println(" Palindrom Checker: ");
        Scanner readIn = new Scanner(System.in);
        System.out.println("Input the word to be tested for Palindrome Property:");
        String str1 = readIn.nextLine();
        if (IsPalindrome(str1))
            System.out.println(str1 + "is a Palindrome string");
        else  
            System.out.println(str1 + "is not a Palindrome string");
      
     }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote