You work at a credit card company and as a value-add they want to start providing alerts to users when their spending in any particular category is higher than usual.
- Compare the total amount paid for the current month, grouped by category with the previous month
- Filter down to the categories for which the user spent at least 50% more this month than last month
- Compose an e-mail message to the user that lists the categories for which spending was unusually high
- private String name; private String email;
- public Customer(String name, String email) public String getName() public String getEmail()
- -private final limit
-
- private enum Category
- private Map<Category, Double> amountForEachCategory
-
- Transaction(Map<Category, Double> amountForEachCategory)
-
- public double totalAmountSpent
- public Map<Category, Double> groupByCategory()
-
- private List previousMonthTransactions
- private List currentMonthTransactions
-
- TransactionAnalyzer(List previousMonthTransactions, List currentMonthTransactions)
-
- public List getPreviousMonthTransactions()
- public List getCurrentMonthTransactions()
- public double totalAmountSpent()
- public double totalAmountSpentInPreviousMonth()
- private double totalAmount(List transactions)
- public Map<Category, Double> totalAmountOfUnusualSpentPerCategory()
- private double getPreviousMonthAmount
- public boolean isUnusualSpending(Transactions transactions)
- void send(Notification notification)
- EmailAlertMessage : message related all formats
- EmailAlertSystem : actual implementation of the code to send email