getMaxRate function

double getMaxRate (
  1. CreditCard card,
  2. 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;
}