Skip to content

Instantly share code, notes, and snippets.

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