Last active
December 24, 2015 11:08
-
-
Save winsonwq/6788448 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Rate : IRate { | |
public Rate(CustomerType, weekdays, weekdayPrice, weekendPrice) { | |
// ..... | |
} | |
public double calculte (Days days...) { | |
double totalPrice = 0; | |
for(var day in days) { | |
if day is weekdays { | |
totoalPrice += weekdayPrice; | |
} else { | |
totalPrice += weekendPrice; | |
} | |
} | |
return totalPrice; | |
} | |
} | |
public enum Day { | |
Mon = 1 | |
Tue = 2 | |
Wed = 4 | |
Thu = 8 | |
Fri = 16 | |
Sat = 32 | |
Sun = 64 | |
} | |
IRate rate = new Rate(CustomerType.Regular, Day.Mon | Day.Tue | Day.Wed, 100, 200); | |
rate.calculate(Day.Mon | Day.Tue | Day.Wed); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment