getMaxRate function
- CreditCard card,
- ShoppingCategory category
Implementation
double getMaxRate(CreditCard card, ShoppingCategory category) {
double maxRate = 0.0;
for (Promotion promo in card.promotions) {
if (isInValidTimeRange(promo)) {
if (promo.category.id == category.id) {
maxRate = max(maxRate, promo.rate);
} else {
if (promo.type == 'universal') {
maxRate = max(maxRate, promo.rate);
}
}
}
}
return maxRate;
}