Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace FactoryMethod
- {
- public interface IPhone
- {
- decimal Price { get; }
- }
- public class Nokia : IPhone
- {
- public decimal Price
- {
- get { return 200; }
- }
- }
- public class Motorola : IPhone
- {
- public decimal Price
- {
- get { return 100; }
- }
- }
- public class PhoneFactory
- {
- public IPhone GetPhone(string type)
- {
- switch (type)
- {
- case "Nokia":
- return new Nokia();
- case "Motorola":
- return new Motorola();
- default:
- return null;
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment