This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public abstract class Phone | |
| { | |
| public abstract void Make(); | |
| } | |
| public class Iphone : Phone | |
| { | |
| public override void Make() | |
| { | |
| Console.WriteLine("Iphone Created\n"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Program | |
| { | |
| static void Main(string[] args) | |
| { | |
| PhoneFactory pf1 = new PhoneFactory(); | |
| pf1.MakePhone(new Iphone()); | |
| PhoneFactory pf2 = new PhoneFactory(); | |
| pf2.MakePhone(new Samsung()); | |
| Console.ReadLine(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class PhoneFactory | |
| { | |
| public void MakePhone(Phone phone) | |
| { | |
| switch (phone.Type) | |
| { | |
| case PhoneType.Iphone: | |
| MakeIphone((Iphone)phone); | |
| break; | |
| case PhoneType.Samsung: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Phone | |
| { | |
| public PhoneType Type { get; set; } | |
| } | |
| public enum PhoneType | |
| { | |
| Iphone, | |
| Samsung | |
| } | |
| public class Iphone : Phone |
NewerOlder