diff --git a/Day 3 Class Examples/example13/Program.cs b/Day 3 Class Examples/example13/Program.cs new file mode 100644 index 0000000..c866fa9 --- /dev/null +++ b/Day 3 Class Examples/example13/Program.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace example13 +{ + abstract class Position + { + public abstract string Title { get; } + } + + class Manager : Position + { + public override string Title + { + get { return "Manager"; } + } + } + + class Clerk : Position + { + public override string Title + { + get { return "Clerk"; } + } + } + + class Programmer : Position + { + public override string Title + { + get { return "Programmer"; } + } + } + + static class Factory + { + public static Position Get(int id) + { + switch (id) + { + case 0: + return new Manager(); + case 1: + return new Clerk(); + default: + return new Programmer(); + } + } + } + + class Program + { + static void Main(string[] args) + { + Console.WriteLine("Position id = {0}, position = {1}", 0, Factory.Get(0)); + } + } +}