mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-19 13:26:33 +00:00
* #1317 Add Special Case Pattern To focus on pattern itself, I implement DB and maintenance lock by the singleton instance. * #1317 Add special cases unit tests Assert the logger output (ref: https://stackoverflow.com/a/52229629) * #1317 Add README.md Add Special Case Pattern README * #1317 Format: add a new line to end of file Co-authored-by: Subhrodip Mohanta <subhrodipmohanta@gmail.com>
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package com.iluwatar.specialcase;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class InsufficientFunds implements ReceiptViewModel {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(InsufficientFunds.class);
|
||||
|
||||
private String userName;
|
||||
private Double amount;
|
||||
private String itemName;
|
||||
|
||||
/**
|
||||
* Constructor of InsufficientFunds.
|
||||
*
|
||||
* @param userName of the user
|
||||
* @param amount of the user's account
|
||||
* @param itemName of the item
|
||||
*/
|
||||
public InsufficientFunds(String userName, Double amount, String itemName) {
|
||||
this.userName = userName;
|
||||
this.amount = amount;
|
||||
this.itemName = itemName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
LOGGER.info("Insufficient funds: " + amount + " of user: " + userName
|
||||
+ " for buying item: " + itemName);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user