Advertisement
Guest User

Untitled

a guest
May 19th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.77 KB | None | 0 0
  1. // Text.cs = Base class
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6.  
  7. namespace Translation
  8. {
  9.     public class Text
  10.     {
  11.         public Text()
  12.         {
  13.  
  14.         }
  15.  
  16.         public virtual string content()
  17.         {
  18.             return "Dat is de text.";
  19.         }
  20.     }
  21. }
  22.  
  23. // CharDecorator.cs
  24.  
  25. using System;
  26. using System.Collections.Generic;
  27. using System.Linq;
  28. using System.Text;
  29.  
  30. using Translation;
  31.  
  32. namespace Translation.Decorator
  33. {
  34.     public abstract class CharDecorator : Text
  35.     {
  36.     }
  37. }
  38.  
  39. // Emphasis.cs
  40.  
  41. using System;
  42. using System.Collections.Generic;
  43. using System.Linq;
  44. using System.Text;
  45.  
  46. using Translation.Decorator;
  47. using Translation;
  48.  
  49. namespace Translation.Decorator.Format
  50. {
  51.     public class Emphasis : CharDecorator
  52.     {
  53.         Text text;
  54.  
  55.         public Emphasis(Text t)
  56.         {
  57.             text = t;
  58.         }
  59.  
  60.         public override string content()
  61.         {
  62.             return "<em>" + text.content() + "</em>";
  63.         }
  64.     }
  65. }
  66.  
  67. // Program.cs
  68.  
  69. using System;
  70. using System.Collections.Generic;
  71. using System.Linq;
  72. using System.Text;
  73.  
  74. using Translation.Decorator.Format;
  75. using Translation.Decorator;
  76.  
  77. namespace Translation
  78. {
  79.     class Program
  80.     {
  81.         private static string inputString;
  82.         static void Main(string[] args)
  83.         {
  84.             Console.WriteLine("Please insert your string that will be translated:");
  85.             Console.WriteLine();
  86.             inputString = Console.ReadLine();
  87.             // Start translation here
  88.             Text text = new Text();
  89.             text = new Emphasis(text);
  90.             // Stop translation here
  91.             Console.WriteLine(text.content());
  92.             Console.ReadLine();
  93.         }
  94.     }
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement