/** * Checks to see if user input is a valid Roman Numeral * * @param input User input of roman numeral * @return a true or false value if validation is true or not */ public boolean validateRomanNumeral(CharacterStack stack) { char[] input = new char[stack.getSize()]; counter++; size[counter] = stack.getSize(); for (int ii = 0; ii < input.length; ii++) { input[ii] = stack.pop(); } Verifier verify = new Verifier(input); int stringLength = input.length; boolean validInput = verify.checkIndividualChar(input); if (validInput == false) { System.out.print("Error: "); System.out.println("There is a character in your input that is not part of a Roman Numeral."); System.out.println(""); return false; } else { // System.out.println("Check individualChar validation successful."); if (stringLength == 1) { return true; } else { boolean isThereRepeats = verify.checkThreeOrMoreNumerals(input); if (isThereRepeats == true) { System.out.print("Error: "); System.out.println("There are more than three consecutive Roman characters."); System.out.println(""); return false; } else { // System.out.println("Check for three or more numerals validation successful"); boolean validRepeats = verify.checkDuplicatesValidTens(input); if (validRepeats == false) { System.out.print("Error: "); System.out.println("There is an invalid roman character consecutively entered"); System.out.println(""); return false; } else { // System.out.println("Check for valid tens power duplicates validation successful"); boolean invalidSmallPower = verify.checkPowerLeftOfNumeral(input); if (invalidSmallPower == true) { System.out.print("Error: "); System.out.println( "There is an invalid roman character left a larger roman character"); System.out.println(""); return false; } else { // System.out.println("Check for valid powers left of larger numbers successful."); boolean invalidPower = verify.checkPowerFrontOfNumeral(input); if (invalidPower == true) { System.out.print("Error: "); System.out.println( "There is an invalid roman character front of a larger roman character"); System.out.println(""); return false; } else { // System.out.println("Check for valid powers front of larger numbers successful"); return true; } } } } } } }