Skip to content

Instantly share code, notes, and snippets.

@winsonwq
Last active December 24, 2015 11:08
Show Gist options
  • Save winsonwq/6788448 to your computer and use it in GitHub Desktop.
Save winsonwq/6788448 to your computer and use it in GitHub Desktop.
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