package org.studiorailgun.sim.writing;

/**
 * Converts a number to words
 */
public class NumberWordizer {
    
    /**
     * Converts a number to a string of words
     * @param num The number
     * @return The string of words
     */
    public static String convert(int num){
        if(num == 0){
            return "zero";
        }
        if(num < 10){
            switch(num){
                case 1: {
                    return "one";
                }
                case 2: {
                    return "two";
                }
                case 3: {
                    return "three";
                }
                case 4: {
                    return "four";
                }
                case 5: {
                    return "five";
                }
                case 6: {
                    return "six";
                }
                case 7: {
                    return "seven";
                }
                case 8: {
                    return "eight";
                }
                case 9: {
                    return "nine";
                }
            }
        }
        throw new Error("Unsupported number " + num);
    }

    /**
     * Gets the tens place word
     * @param num The number
     * @return The tens place word
     */
    public static String getTensPlace(int num){
        int divResult = num / 10;
        switch(divResult){
            case 2: {
                return "twenty";
            }
            case 3: {
                return "thirty";
            }
            case 4: {
                return "fourty";
            }
            case 5: {
                return "fifty";
            }
            case 6: {
                return "sixty";
            }
            case 7: {
                return "seventy";
            }
            case 8: {
                return "eighty";
            }
            case 9: {
                return "ninety";
            }
            case 1:
            case 0:
            default: {
                throw new Error("Unhandled value!");
            }
        }
    }

}
