package com.ffii.core.utils;

public class RomanConverter {
    private static final int[] VALUES = { 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1 };
    private static final String[] CAP_SYMBOLS = { "M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I" };
    private static final String[] SYMBOLS = { "m", "cm", "d", "cd", "c", "xc", "l", "xl", "x", "ix", "v", "iv", "i" };

    public static String convertToRoman(int number, boolean isCapitalLetter) {
        if (number <= 0 || number > 3999) {
            throw new IllegalArgumentException("Number out of range. Please provide a value between 1 and 3999.");
        }

        StringBuilder roman = new StringBuilder();

        for (int i = 0; i < VALUES.length; i++) {
            while (number >= VALUES[i]) {
                roman.append(isCapitalLetter ? CAP_SYMBOLS[i] : SYMBOLS[i]);
                number -= VALUES[i];
            }
        }

        return roman.toString();
    }
}
