Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rightson/9ae057ce92ea88d59890ea3966167cc5 to your computer and use it in GitHub Desktop.
Save rightson/9ae057ce92ea88d59890ea3966167cc5 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