using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AbstractFactoryDesignPattern
{
public interface IMobilePhone
{
ISmartPhone GetSmartPhone();
INormalPhone GetNormalPhone();
}
public class Nokia : IMobilePhone
{
public INormalPhone GetNormalPhone()
{
return new Nokia1600();
}
public ISmartPhone GetSmartPhone()
{
return new Nokia3600();
}
}
public class Smasung : IMobilePhone
{
public INormalPhone GetNormalPhone()
{
return new SamsungGuru();
}
public ISmartPhone GetSmartPhone()
{
return new SamsungGalaxy();
}
}
public class Nokia1600 : INormalPhone
{
public string GetModelDetails()
{
return "nokia 1600 normal model";
}
}
public class Nokia3600 : ISmartPhone
{
public string GetModelDetails()
{
return "nokia 3600 smart model";
}
}
public class SamsungGuru : INormalPhone
{
public string GetModelDetails()
{
return "samsung guru normal model";
}
}
public class SamsungGalaxy : ISmartPhone
{
public string GetModelDetails()
{
return "samsung galaxy smart model";
}
}
public interface ISmartPhone
{
string GetModelDetails();
}
public interface INormalPhone
{
string GetModelDetails();
}
class MobileClient
{
ISmartPhone _smartPhone;
INormalPhone _normalPhone;
public MobileClient(IMobilePhone mobile)
{
this._smartPhone = mobile.GetSmartPhone();
this._normalPhone = mobile.GetNormalPhone();
}
public string getSmartPhoneModelDetails()
{
return _smartPhone.GetModelDetails();
}
public string getNormalPhoneModelDetails()
{
return _normalPhone.GetModelDetails();
}
}
class AbstractFactoryDesignPattern
{
static void Main(string[] args)
{
IMobilePhone nokiaPhone = new Nokia();
MobileClient nokiaClient = new MobileClient(nokiaPhone);
Console.WriteLine("********* NOKIA **********");
Console.WriteLine(nokiaClient.getNormalPhoneModelDetails());
Console.WriteLine(nokiaClient.getSmartPhoneModelDetails());
IMobilePhone samsungPhone = new Smasung();
MobileClient samsungClient = new MobileClient(samsungPhone);
Console.WriteLine("********* Smasung **********");
Console.WriteLine(samsungClient.getNormalPhoneModelDetails());
Console.WriteLine(samsungClient.getSmartPhoneModelDetails());
Console.ReadLine();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AbstractFactoryDesignPattern
{
public interface IMobilePhone
{
ISmartPhone GetSmartPhone();
INormalPhone GetNormalPhone();
}
public class Nokia : IMobilePhone
{
public INormalPhone GetNormalPhone()
{
return new Nokia1600();
}
public ISmartPhone GetSmartPhone()
{
return new Nokia3600();
}
}
public class Smasung : IMobilePhone
{
public INormalPhone GetNormalPhone()
{
return new SamsungGuru();
}
public ISmartPhone GetSmartPhone()
{
return new SamsungGalaxy();
}
}
public class Nokia1600 : INormalPhone
{
public string GetModelDetails()
{
return "nokia 1600 normal model";
}
}
public class Nokia3600 : ISmartPhone
{
public string GetModelDetails()
{
return "nokia 3600 smart model";
}
}
public class SamsungGuru : INormalPhone
{
public string GetModelDetails()
{
return "samsung guru normal model";
}
}
public class SamsungGalaxy : ISmartPhone
{
public string GetModelDetails()
{
return "samsung galaxy smart model";
}
}
public interface ISmartPhone
{
string GetModelDetails();
}
public interface INormalPhone
{
string GetModelDetails();
}
class MobileClient
{
ISmartPhone _smartPhone;
INormalPhone _normalPhone;
public MobileClient(IMobilePhone mobile)
{
this._smartPhone = mobile.GetSmartPhone();
this._normalPhone = mobile.GetNormalPhone();
}
public string getSmartPhoneModelDetails()
{
return _smartPhone.GetModelDetails();
}
public string getNormalPhoneModelDetails()
{
return _normalPhone.GetModelDetails();
}
}
class AbstractFactoryDesignPattern
{
static void Main(string[] args)
{
IMobilePhone nokiaPhone = new Nokia();
MobileClient nokiaClient = new MobileClient(nokiaPhone);
Console.WriteLine("********* NOKIA **********");
Console.WriteLine(nokiaClient.getNormalPhoneModelDetails());
Console.WriteLine(nokiaClient.getSmartPhoneModelDetails());
IMobilePhone samsungPhone = new Smasung();
MobileClient samsungClient = new MobileClient(samsungPhone);
Console.WriteLine("********* Smasung **********");
Console.WriteLine(samsungClient.getNormalPhoneModelDetails());
Console.WriteLine(samsungClient.getSmartPhoneModelDetails());
Console.ReadLine();
}
}
}
No comments:
Post a Comment