Mega Code Archive

 
Categories / C# Tutorial / Design Patterns
 

MVC Patterns

using System; using System.Collections.Generic; using System.Text;     interface IController     {        void DisplayPrice();     }     public class Model     {         public double Price()         {             return 100;         }     }     public class FirstController: IController     {       private Model mod;       public void DisplayPrice()       {         double cost = mod.Price() * 1.15;         String message = "first USD " + cost.ToString();         Console.WriteLine(message);       }       public FirstController()       {         mod = new Model();       }     }         public class SecondController: IController     {       private Model mod;         public void DisplayPrice()       {             double cost = mod.Price()*1.1;             String message = "second USD " + cost.ToString();             Console.WriteLine(message);       }       public SecondController()       {         mod = new Model();       }     }     public class Client     {         static void Main(string[] args)         {           SecondController viewUS = new SecondController();           viewUS.DisplayPrice();           FirstController viewNorway = new FirstController();           viewNorway.DisplayPrice();         }     }