Skip to content

Instantly share code, notes, and snippets.

View iamcrypticcoder's full-sized avatar

Mahbubur Rahman iamcrypticcoder

View GitHub Profile
protocol AbstractGUIFactory {
func createButton() -> Button
func createWindow() -> Window
}
class WinButton: Button {
var title: String?
func setTitle(_ title: String) -> Void {
self.title = title
}
func show() -> Void {
print("Showing Windows style button [Title: \(self.title!)]")
}
protocol Button {
func setTitle(_ title: String) -> Void
func show() -> Void
}
protocol Window {
func setTitle(_ title: String) -> Void
func show() -> Void
}
class GUIBuilder {
private var platform: String
private var guiFactory: AbstractGUIFactory?
init(platform: String) {
self.platform = platform
}
func initGuiFactory() -> Void {
if nil != guiFactory { return }