static void Main(string[] args) { if (args.GetLength(0) != 3) { Console.WriteLine("Niewłaściwa ilość argumentów"); Console.ReadKey(); Environment.Exit(1); } CurrencyDataManagment first = new CurrencyDataManagment(args[0]); CurrencyDataManagment second = new CurrencyDataManagment(args[2]); double amountOfMoneyToConvert = 0; try { amountOfMoneyToConvert = Convert.ToDouble(args[1]); } catch (FormatException) { Console.WriteLine("Zły format kwoty"); Console.ReadKey(); Environment.Exit(2); } Console.WriteLine("Kurs waluty " + first.CurrencySymbol + " wynosi: " + first.CurrencyValue); Console.WriteLine("Kurs waluty " + second.CurrencySymbol + " wynosi: " + second.CurrencyValue); Console.WriteLine(args[1] + " " + first.CurrencySymbol + " = " + Converter.Convert(amountOfMoneyToConvert, first, second) + " " + second.CurrencySymbol); Console.ReadKey(); }
public static double Convert(double amountOfMoney, CurrencyDataManagment primary, CurrencyDataManagment secondary) { return(amountOfMoney * primary.CurrencyValue / secondary.CurrencyValue); }