Created
January 1, 2019 15:26
-
-
Save LH17/7c40e920120128bb116d7e661651fd90 to your computer and use it in GitHub Desktop.
Template Design Pattern
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
protocol Office { | |
func officeSchedule() | |
} | |
protocol Employee { | |
func work() | |
func getPaid() | |
} | |
class XYZOffice: Office { | |
var delegate: Employee | |
init(employee: Employee) { | |
self.delegate = employee | |
} | |
func officeSchedule() { | |
delegate.work() | |
delegate.getPaid() | |
} | |
} | |
class Developer: Employee { | |
func work() { | |
print("Developer has worked 40 hours/week this month") | |
} | |
func getPaid() { | |
print("Developer has earned Rs 50,000 this month") | |
} | |
} | |
class ProductManager: Employee { | |
func work() { | |
print("Product Manager has worked 55 hours/week this month") | |
} | |
func getPaid(){ | |
print("Product Manager has earned Rs 80,000 this month") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment