Last active
August 29, 2016 12:00
-
-
Save r-winkler/45a31a10ade7989d9132444f7f6e77b6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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