Skip to content

Instantly share code, notes, and snippets.

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