hello any guidance on this would be greatly appreciated( im very new to programming the more comments the better)
the objective is to create a class that defines a single String data member. The class should define a isPalindrome method which returns true when the String is a Palindrome and false otherwise. The class's toString method should return the String data member along with the result of the isPalindrome method is a readable format.
then you need a client application and its responsible for retrieving a word or sentence from the user, passing the input String to the class and calling the toString method. The client should allow the user to test any number of strings.
Heres what i got so far:
import java.lang.String;
import java.lang.Object;
public class Palindrome
{
private String palin;
public Palindrome()
{
palin = " ";
}
public Palindrome(String newPalin, String initPalin)
{
palin = initPalin.toUpperCase();
palin = newPalin;
}
public String getPalin()
{
return palin;
}
public void setPalin(String newPalin)
{
palin = newPalin;
}
public static boolean isPalindrome(String palin)
{
int left = 0;
int right = palin.length() -1;
while (left < right)
{
if (palin.charAt(left) != palin.charAt(right))
{
return false;
}
left++;
right--;
}
return true;
}
public String toString()
{
return isPalindrome();
}
}
Thats ^^ the standard class ( which is incomplete) and as far as my client goes this is where im confused and cant figure out how to do any of it
import java.util.Scanner;
import java.lang.String;
public class palinClient
{
public static void main(String[] args)
{
String entry;
Scanner scan = new Scanner(System.in);
Palindrome palin1 = new Palindrome();
System.out.println("Please enter your expression");
entry = scan.next();
palin1.setPalin(entry);
}
}
Ty for the Help!!