Created
March 29, 2018 09:55
-
-
Save iamcrypticcoder/39e0ea72d7a07968ef5d2ef273d210f1 to your computer and use it in GitHub Desktop.
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
class GUIBuilder { | |
private var platform: String | |
private var guiFactory: AbstractGUIFactory? | |
init(platform: String) { | |
self.platform = platform | |
} | |
func initGuiFactory() -> Void { | |
if nil != guiFactory { return } | |
if platform == "Windows" { guiFactory = WinFactory() } | |
else { guiFactory = OSXFactory() } | |
} | |
func buildButton() -> Button { | |
initGuiFactory() | |
return guiFactory!.createButton() | |
} | |
func buildWindow() -> Window { | |
initGuiFactory() | |
return guiFactory!.createWindow() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment