Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save rightson/4afe31223b9cc8f61a06e648ef34a335 to your computer and use it in GitHub Desktop.

Select an option

Save rightson/4afe31223b9cc8f61a06e648ef34a335 to your computer and use it in GitHub Desktop.
private double amountFor(Rental each) {
double thisAmount = 0;
switch (each.getMovie().getPriceCode()) {
case Movie.REGULAR:
thisAmount += 2;
if (each.getDaysRented() > 2)
thisAmount += (each.getDaysRented() - 2) * 1.5;
break;
case Movie.NEW_RELEASE:
thisAmount += each.getDaysRented() * 3;
break;
case Movie.CHILDRENS:
thisAmount += 1.5;
if (each.getDaysRented() > 3)
thisAmount += (each.getDaysRented() - 3) * 1.5;
break;
}
return thisAmount;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment