/* * Program class to test out the two * different Roman Numeral Classes * * CS112 * * Christine Papadakis-Kanaris * */ public class TestRomanNumerals { /* * Separate driver main method to test * the methods of our classes */ public static void main(String[] args) { System.out.printf("Simple static calls to Roman.java\n"); System.out.printf("\tX + XI = %d\n", RomanNumeralStatic.add("X", "XI")); System.out.printf("\tLXI = %d\n", RomanNumeralStatic.convert("LXI")); System.out.printf("Roman Object Manipulation\n"); RomanNumeral r1 = new RomanNumeral("X"); RomanNumeral r2 = new RomanNumeral("VI"); RomanNumeral r3 = new RomanNumeral("XIV"); System.out.printf("\t%s + %s = %d\n", r1, r2, r1.add(r2)); System.out.printf("\t%s + %s = %d\n", r1, r3, r1.add(r3)); System.out.printf("\t%s + %s = %d\n", r2, r3, r2.add(r3)); String[] lstStringRoman = {"X", "LX", "XII", "IX", "XXI"}; RomanNumeral[] lstRoman = new RomanNumeral[lstStringRoman.length]; for (int k = 0 ; k < lstStringRoman.length ; k++) { lstRoman[k] = new RomanNumeral(lstStringRoman[k]); } System.out.printf("Printing out roman numeral strings with their int values\n"); for (int n = 0 ; n < lstStringRoman.length ; n++) { System.out.printf( "\t%s -> %d\n" , lstStringRoman[n] , RomanNumeralStatic.convert(lstStringRoman[n])); } System.out.printf("Printing out roman numeral objects with their int values\n"); for (int n = 0 ; n < lstStringRoman.length ; n++) { System.out.printf( "\t%s -> %d\n" , lstRoman[n] , RomanNumeralStatic.convert(lstStringRoman[n]) ); } } // end of main() method } // end of class defintion