Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Bridge Design Patern
//Bridge //Abstraction decoupled from implementation //Additional Abstraction so that first abstraction and its implementation can vary independently using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { List<Manuscript> docs = new List<Manuscript>(); var formatter = new MirrorFormatter(); var book = new Book(formatter) { Title = "Tytulik", Author = "Autorek PW", Text = "Tekścik" }; docs.Add(book); foreach(var doc in docs) { doc.Print(); } } public abstract class Manuscript { protected readonly IFormatter formatter; public Manuscript(IFormatter formatter) { this.formatter = formatter; } abstract public void Print(); } public class Book : Manuscript { public Book(IFormatter formatter) : base(formatter) {} public string Title {get; set;} public string Author {get; set;} public string Text {get; set;} override public void Print() { Console.WriteLine(formatter.Format("Tile", Title)); Console.WriteLine(formatter.Format("Author", Author)); Console.WriteLine(formatter.Format("Text", Text)); } } public interface IFormatter { string Format(string key, string value); } class StandardFormatter : IFormatter { public string Format(string key, string value) { return string.Format("{0}: {1}",key, value); } } class MirrorFormatter : IFormatter { public string Format(string key, string value) { return string.Format("{0}: {1}", key, new string(value.Reverse().ToArray())); } } } }
run
|
edit
|
history
|
help
0
n th to last element
בדיקה כמה פעמים מערך אחד כלול במערך אחר
3
Delegates
FileNameCharCheck
Is String a Palindrome
Square Integer Matrix
1
ss
Random number generator With IF's that sometimes cant count