fork download
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. MainX(new String[] { "50", "Fahrenheit", "To", "Celsius"});
  9. }
  10.  
  11. delegate double TemperatureConvert(double valor);
  12.  
  13. static Dictionary<String, TemperatureConvert> converters = new Dictionary<string, TemperatureConvert>
  14. {
  15. {"CelsiusToFahrenheit", TemperatureConverter.CelsiusToFahrenheit},
  16. {"CelsiusToKelvin", TemperatureConverter.CelsiusToKelvin},
  17. {"FahrenheitToCelsius", TemperatureConverter.FahrenheitToCelsius},
  18. {"FahrenheitToKelvin", TemperatureConverter.FahrenheitToKelvin},
  19. {"KelvinToFahrenheit", TemperatureConverter.KelvinToFahrenheit},
  20. {"KelvinToCelsius", TemperatureConverter.KelvinToCelsius}
  21. };
  22.  
  23. static void MainX(string[] args)
  24. {
  25. var temperature = double.Parse(args[0]);
  26. var conversor = args[1] + args[2] + args[3];
  27.  
  28. var convertedTemperature = converters[conversor](temperature);
  29.  
  30. Console.WriteLine(convertedTemperature);
  31. }
  32. }
  33.  
  34. public static class TemperatureConverter
  35. {
  36. public static double CelsiusToFahrenheit(double valor)
  37. {
  38. Console.WriteLine("CelsiusToFahrenheit " + valor);
  39. return valor;
  40. }
  41. public static double CelsiusToKelvin(double valor)
  42. {
  43. Console.WriteLine("CelsiusToKelvin" + valor);
  44. return valor;
  45. }
  46. public static double FahrenheitToCelsius(double valor)
  47. {
  48. Console.WriteLine("FahrenheitToCelsius" + valor);
  49. return valor;
  50. }
  51. public static double FahrenheitToKelvin(double valor)
  52. {
  53. {
  54. Console.WriteLine("FahrenheitToKelvin" + valor);
  55. return valor;
  56. }
  57. }
  58. public static double KelvinToFahrenheit(double valor)
  59. {
  60. Console.WriteLine("KelvinToFahrenheit" + valor);
  61. return valor;
  62. }
  63. public static double KelvinToCelsius(double valor)
  64. {
  65. Console.WriteLine("KelvinToCelsius" + valor);
  66. return valor;
  67. }
  68. }
Success #stdin #stdout 0s 29808KB
stdin
Standard input is empty
stdout
FahrenheitToCelsius50
50