/* Name: Joseph Schuman Date: 3/15/2015 File: Chapter 10 Assignment, TestMiscStringClass Descripetion: Test a string by calling the MiscString class and AnyString class. Creates a String array and calls the MiscString class and AnyString class. */ import java.util.Scanner; public class TestMiscStringClass { public static void main(String[] args) { String s; Scanner input = new Scanner(System.in); while(true) { System.out.println(); System.out.print("Input string: "); s = input.nextLine(); if(s.equals("")) { break; } MiscString strObj = new MiscString(s); System.out.println(); System.out.println("*****String Check*****"); System.out.println(); System.out.println("String input: " + s); System.out.println("Object string: " + strObj.getString()); System.out.println("Is object palindrome: " + strObj.checkPalindrome()); System.out.println("Is object numeric palindrome: " + strObj.checkNumericPalindrome()); System.out.println("Is palindrome: " + MiscString.checkPalindrome(s)); System.out.println("Object string length: " + strObj.getLength()); System.out.println("Object string toString: " + strObj.toString()); System.out.println("Object string lowercase: " + strObj.toLowerCase()); System.out.println("Object string uppercase: " + strObj.toUpperCase()); MiscString obj = new MiscString("abc"); System.out.println("Object string equal: " + strObj.equals(obj)); System.out.println("Object string isLetters: " + strObj.isLetters()); System.out.println("Object string isNumeric: " + strObj.isNumeric()); } char[] chArray = {'a', 'b', 'c'}; MiscString strObj = new MiscString(chArray); System.out.println(); System.out.println("*****Character Array Check*****"); System.out.println(); System.out.println("String input: " + s); System.out.println("Object string: " + strObj.getString()); System.out.println("Is object palindrome: " + strObj.checkPalindrome()); System.out.println("Is object numeric palindrome: " + strObj.checkNumericPalindrome()); System.out.println("Is palindrome: " + MiscString.checkPalindrome(s)); System.out.println("Object string length: " + strObj.getLength()); System.out.println("Object string toString: " + strObj.toString()); System.out.println("Object string lowercase: " + strObj.toLowerCase()); System.out.println("Object string uppercase: " + strObj.toUpperCase()); MiscString obj = new MiscString("abc"); System.out.println("Object string equal: " + strObj.equals(obj)); System.out.println("Object string isLetters: " + strObj.isLetters()); System.out.println("Object string isNumeric: " + strObj.isNumeric()); } } /* Name: Joseph Schuman Date: 3/15/2015 File: Chapter 10 Assignment, MiscString Descripetion: Contains code to manipulate a string and check to see if a string is all characters, numbers, and equals to a certain string. Shares abstract class with AnyString class. */ public class MiscString extends AnyString { // Constructor method - sets the object variable to // the string passed to it public MiscString(String s) { super(s); } // Constructor method - sets the object variable to // the character array passed to it public MiscString(char[] chArray) { super(chArray); } // Returns a lowercase string value public String toLowerCase() { return str.toLowerCase(); } // Returns a uppercase string value public String toUpperCase() { return str.toUpperCase(); } // Object/Instance method to determine if the object is a // palindrome public boolean checkPalindrome() { // Convert to lowercase for testing - create resultString // to hold all the letters detected in lowerString String lowerString = str.toLowerCase(); String resultString = ""; // If letter found store it in resultString for(int i=0; i