Created
May 21, 2018 16:29
-
-
Save aliozgur/91a969449174b041cfc3637bfc8a72eb to your computer and use it in GitHub Desktop.
GoF-Abstract Factory
This file contains 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
using System; | |
namespace GofFactory_Revisited | |
{ | |
public enum PlatformType | |
{ | |
Mobile, | |
Desktop | |
} | |
interface IDrawable | |
{ | |
void Draw(); | |
} | |
interface IStatusBar:IDrawable | |
{ | |
void AddButton(IButton button); | |
} | |
interface IButton:IDrawable | |
{ | |
string Caption { get; set; } | |
} | |
class DesktopButton : IButton | |
{ | |
public string Caption { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } | |
public void Draw() | |
{ | |
// | |
} | |
} | |
class MobileButton : IButton | |
{ | |
public string Caption { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } | |
public void Draw() | |
{ | |
throw new NotImplementedException(); | |
} | |
} | |
class MobileStatusBar : IStatusBar | |
{ | |
public void AddButton(IButton button) | |
{ | |
throw new NotImplementedException(); | |
} | |
public void Draw() | |
{ | |
throw new NotImplementedException(); | |
} | |
} | |
class DesktopStatusBar : IStatusBar | |
{ | |
public void AddButton(IButton button) | |
{ | |
throw new NotImplementedException(); | |
} | |
public void Draw() | |
{ | |
throw new NotImplementedException(); | |
} | |
} | |
interface IGuiFactory | |
{ | |
IButton GetButton(); | |
IStatusBar GetStatusBar(); | |
} | |
class DesktopGuiFactory : IGuiFactory | |
{ | |
public IButton GetButton() | |
{ | |
return new DesktopButton(); | |
} | |
public IStatusBar GetStatusBar() | |
{ | |
return new DesktopStatusBar(); | |
} | |
} | |
class MobileGuiFactory : IGuiFactory | |
{ | |
public IButton GetButton() | |
{ | |
return new MobileButton(); | |
} | |
public IStatusBar GetStatusBar() | |
{ | |
return new MobileStatusBar(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment