Skip to content

Instantly share code, notes, and snippets.

@r-winkler
Last active August 29, 2016 12:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save r-winkler/45a31a10ade7989d9132444f7f6e77b6 to your computer and use it in GitHub Desktop.
Save r-winkler/45a31a10ade7989d9132444f7f6e77b6 to your computer and use it in GitHub Desktop.
public double totalAmount(List<Items> items) {
double total = 0.0;
for (item : items) {
if (item.getCategory() == "DISCOUNT") {
total += 0.95 * item.getPrice();
}
else if (item.getCategory() == "WEIGHT") {
total += item.getQuantity()*5/1000);
}
else if (item.getCategory() =="SPECIAL") {
total += 0.8*item.getPrice();
}
// more rules are coming!
}
return total;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment