docs: update special case

This commit is contained in:
Ilkka Seppälä
2024-05-21 11:43:30 +03:00
parent dde2a78a46
commit 3703aa6e64
5 changed files with 195 additions and 325 deletions
@@ -26,6 +26,8 @@ package com.iluwatar.specialcase;
import java.util.HashMap;
import java.util.Map;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
/**
* DB class for seeding user info.
@@ -119,17 +121,11 @@ public class Db {
/**
* User class to store user info.
*/
@RequiredArgsConstructor
@Getter
public class User {
private String userName;
public User(String userName) {
this.userName = userName;
}
public String getUserName() {
return userName;
}
private final String userName;
public ReceiptDto purchase(Product item) {
return new ReceiptDto(item.getPrice());
@@ -139,13 +135,11 @@ public class Db {
/**
* Account info.
*/
public class Account {
@RequiredArgsConstructor
@Getter
public static class Account {
private Double amount;
public Account(Double amount) {
this.amount = amount;
}
private final Double amount;
/**
* Withdraw the price of the item from the account.
@@ -159,25 +153,15 @@ public class Db {
}
return new MoneyTransaction(amount, price);
}
public Double getAmount() {
return amount;
}
}
/**
* Product info.
*/
public class Product {
@RequiredArgsConstructor
@Getter
public static class Product {
private Double price;
public Product(Double price) {
this.price = price;
}
public Double getPrice() {
return price;
}
private final Double price;
}
}
@@ -24,6 +24,7 @@
*/
package com.iluwatar.specialcase;
import lombok.Getter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -35,6 +36,8 @@ public class MaintenanceLock {
private static final Logger LOGGER = LoggerFactory.getLogger(MaintenanceLock.class);
private static MaintenanceLock instance;
@Getter
private boolean lock = true;
/**
@@ -49,10 +52,6 @@ public class MaintenanceLock {
return instance;
}
public boolean isLock() {
return lock;
}
public void setLock(boolean lock) {
this.lock = lock;
LOGGER.info("Maintenance lock is set to: {}", lock);
@@ -24,16 +24,14 @@
*/
package com.iluwatar.specialcase;
import lombok.RequiredArgsConstructor;
/**
* Represents the money transaction taking place at a given moment.
*/
@RequiredArgsConstructor
public class MoneyTransaction {
private Double amount;
private Double price;
public MoneyTransaction(Double amount, Double price) {
this.amount = amount;
this.price = price;
}
private final Double amount;
private final Double price;
}
@@ -24,26 +24,22 @@
*/
package com.iluwatar.specialcase;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Receipt view representing the transaction recceipt.
*/
@RequiredArgsConstructor
@Getter
public class ReceiptDto implements ReceiptViewModel {
private static final Logger LOGGER = LoggerFactory.getLogger(ReceiptDto.class);
private final Double price;
public ReceiptDto(Double price) {
this.price = price;
}
public Double getPrice() {
return price;
}
@Override
public void show() {
LOGGER.info(String.format("Receipt: %s paid", price));