Пример #1
0
//calcualtes the amount for a rental
double Customer::amountFor(const Rental& r) const{
  double thisAmount = 0;
  if(r.getVideo().getCode() == Video::REGULAR) {
    thisAmount += 2;
    if (r.getDaysRented() > 2)
      thisAmount += (r.getDaysRented() - 2) * 1.5;
  }

  else if(r.getVideo().getCode() ==Video::NEW_RELEASE) {
    thisAmount += r.getDaysRented() * 3;
  }

  else if(r.getVideo().getCode() == Video::CHILDRENS) {
    thisAmount += 1.5;
    if (r.getDaysRented() > 3)
      thisAmount += (r.getDaysRented() - 3) * 1.5;
    }
  return thisAmount;
}
Пример #2
0
// calculates amount for current statement
double Customer::amountFor(const Rental& rental) const {

  double thisAmount = 0;
  switch(rental.getVideo().getCode()) {

      case Video::REGULAR:
      thisAmount += 2;
      if (rental.getDaysRented() > 2)
          thisAmount += (rental.getDaysRented() - 2) * 1.5;
      break;

      case Video::NEW_RELEASE:
      thisAmount += rental.getDaysRented() * 3;
      break;

      case Video::CHILDRENS:
      thisAmount += 1.5;
      if (rental.getDaysRented() > 3)
          thisAmount += (rental.getDaysRented() - 3) * 1.5;
      break;
  }

  return thisAmount;
}