Ad

Just added some additional classes and functions to help make it modular and so others can build ontop of it.

Code
Diff
  • using System;
    using System.Collections.Generic;
    using System.Linq;
    
    class Kata {
        public static string Main(string language) {
          var salutations = new DeveloperGreeting().GreetMyDeveloper(language);
          Console.Write(salutations);
          return salutations;
        }
    }
    
    //Returns the developer greeting message.
    class DeveloperGreeting {
        public string GreetMyDeveloper(string language){
          return new GreetingRepository().GetDeveloperGreetings(language).message;
        }
    }
    
    //Get greeting data from either a collection or database store.
    class GreetingRepository {
       public List<Greeting> greetings;
       
       public GreetingRepository() {
         greetings = new List<Greeting>(){
           new Greeting(){language = "C#", message = "Hello my fellow C# developers, work hard."},
           new Greeting() {language = "Java", message = "Hello my fellow Java developers, work hard."}
         };
       }
       public Greeting GetDeveloperGreetings(string language){
         var g = greetings.Where(x => x.language.Equals(language)).ToList();
         return new Greeting(){ language = g[0].language, message = g[0].message};
       }
    }
    
    //Greeting Model class
    class Greeting{
      public string language {get; set;}
      public string message {get; set;}
    }
    
    
    
    • using System;
    • using System.Collections.Generic;
    • using System.Linq;
    • class Kata {
    • public static string Main(string greeting, string language) {
    • Console.Write("{0}, {1}!\n", greeting, language);
    • return greeting + ", " + language + "!";
    • public static string Main(string language) {
    • var salutations = new DeveloperGreeting().GreetMyDeveloper(language);
    • Console.Write(salutations);
    • return salutations;
    • }
    • }
    • }
    • //Returns the developer greeting message.
    • class DeveloperGreeting {
    • public string GreetMyDeveloper(string language){
    • return new GreetingRepository().GetDeveloperGreetings(language).message;
    • }
    • }
    • //Get greeting data from either a collection or database store.
    • class GreetingRepository {
    • public List<Greeting> greetings;
    • public GreetingRepository() {
    • greetings = new List<Greeting>(){
    • new Greeting(){language = "C#", message = "Hello my fellow C# developers, work hard."},
    • new Greeting() {language = "Java", message = "Hello my fellow Java developers, work hard."}
    • };
    • }
    • public Greeting GetDeveloperGreetings(string language){
    • var g = greetings.Where(x => x.language.Equals(language)).ToList();
    • return new Greeting(){ language = g[0].language, message = g[0].message};
    • }
    • }
    • //Greeting Model class
    • class Greeting{
    • public string language {get; set;}
    • public string message {get; set;}
    • }