/*
 * @topic T10016 Date to words demo
 * @brief main driver program
*/

package a1_demo;

import java.util.Scanner;

public class MainApp {

    public static void main(String[] args) {
        
        while ( true ) {
            // get user input
            String str_MM_DD_YYYY = Validator.getString(
                    Validator.sc,
                    "Enter date in MM/DD/YYYY format: "
            );

            // convert text to ints:
            // "11/22/3333" - > int, int int
            String[] dateComponents = str_MM_DD_YYYY.split( "/" );
            if ( dateComponents.length != 3  ) {
                System.out.println("\t\t Bad input, please retry...");
                continue;
            }

            int month = 0;
            int day = 0;
            int year = 0;
            try {
                month = Integer.parseInt(dateComponents[ 0 ]);
                day = Integer.parseInt(dateComponents[ 1 ]);
                year = Integer.parseInt(dateComponents[ 2 ]);
            } catch ( java.lang.NumberFormatException ex ) {
                System.out.println("\t\t numeric values are expected, please retry...");
                continue;
            }

            Date2TextConverter converter = new Date2TextConverter( month, day, year );

            System.out.print( converter.month2text() );
            System.out.print( " " );
            System.out.print( converter.day2text() );
            System.out.print( " " );
            System.out.print( converter.year2text() );
            System.out.println();
        }// endless while loop

    }//main
    
}//class MainApp