﻿using System;

namespace DiscountOffers
{
    /// <summary>
    /// Solution for https://www.codeeval.com/public_sc/48/.
    /// <author>Swati Swoboda (swati.swoboda@gmail.com)</author>
    /// <example>DiscountOffers {fileName}</example>
    /// </summary>
    public sealed class Program
    {
        private static void Main(string[] args)
        {
            if (args.Length !=  1 || string.IsNullOrWhiteSpace(args[0]))
            {
                Console.Error.WriteLine("Please specify a single file name.");
                Console.Error.WriteLine("Usage: DiscountOffers <fileName>");
                return;
            }

            var path = args[0];
            var parser = new FileParser(path);

            try
            {
                foreach (var score in parser.Scores)
                {
                    Console.WriteLine(score.ToString("F"));
                }
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine($"{ex.Message}. Stopping.");
            }
        }
    }
}
