Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Text.cs = Base class
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace Translation
- {
- public class Text
- {
- public Text()
- {
- }
- public virtual string content()
- {
- return "Dat is de text.";
- }
- }
- }
- // CharDecorator.cs
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Translation;
- namespace Translation.Decorator
- {
- public abstract class CharDecorator : Text
- {
- }
- }
- // Emphasis.cs
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Translation.Decorator;
- using Translation;
- namespace Translation.Decorator.Format
- {
- public class Emphasis : CharDecorator
- {
- Text text;
- public Emphasis(Text t)
- {
- text = t;
- }
- public override string content()
- {
- return "<em>" + text.content() + "</em>";
- }
- }
- }
- // Program.cs
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Translation.Decorator.Format;
- using Translation.Decorator;
- namespace Translation
- {
- class Program
- {
- private static string inputString;
- static void Main(string[] args)
- {
- Console.WriteLine("Please insert your string that will be translated:");
- Console.WriteLine();
- inputString = Console.ReadLine();
- // Start translation here
- Text text = new Text();
- text = new Emphasis(text);
- // Stop translation here
- Console.WriteLine(text.content());
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement