Skip to content

Commit 7bbdf89

Browse files
fix: Apply Google Java Format style guidelines for Spotless compliance
1 parent 07119bb commit 7bbdf89

File tree

6 files changed

+32
-12
lines changed

6 files changed

+32
-12
lines changed

lesson_17/bank/bank_app/src/main/java/com/codedifferently/lesson17/bank/BankAtm.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,11 @@ public void depositFunds(String accountNumber, double amount, Currency currency)
7878
Account account = getAccountOrThrow(accountNumber);
7979
double usdAmount = CurrencyConverter.convertToUSD(amount, currency);
8080
account.deposit(usdAmount);
81-
auditLog.recordCredit(accountNumber, usdAmount,
82-
"Cash deposit" + (currency != Currency.USD ? " (converted from " + currency + ")" : ""));
81+
String description = "Cash deposit";
82+
if (currency != Currency.USD) {
83+
description += " (converted from " + currency + ")";
84+
}
85+
auditLog.recordCredit(accountNumber, usdAmount, description);
8386
}
8487

8588
/**

lesson_17/bank/bank_app/src/main/java/com/codedifferently/lesson17/bank/BankAtmDemo.java

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ public static void main(String[] args) {
5656

5757
MoneyOrder moneyOrder = new MoneyOrder("MO001", 500.0, businessAccount);
5858
System.out.println("Created money order for $500 from business account");
59-
System.out.println("Business account after money order creation: $" + businessAccount.getBalance());
59+
System.out.println(
60+
"Business account after money order creation: $" + businessAccount.getBalance());
6061

6162
bankAtm.depositFunds("CHK001", moneyOrder);
6263
System.out.println("Deposited money order into checking account");
@@ -70,7 +71,8 @@ public static void main(String[] args) {
7071

7172
System.out.println("Deposited $200 check from checking to savings");
7273
System.out.println("Checking balance: $" + checkingAccount.getBalance());
73-
System.out.println("Savings balance: $" + String.format("%.2f", savingsAccount.getBalance()));
74+
System.out.println(
75+
"Savings balance: $" + String.format("%.2f", savingsAccount.getBalance()));
7476
System.out.println();
7577

7678
// 6. Show audit trail
@@ -81,15 +83,25 @@ public static void main(String[] args) {
8183
System.out.println("\nChecking account transactions:");
8284
var checkingTransactions = bankAtm.getAuditLog().getTransactionsForAccount("CHK001");
8385
for (var transaction : checkingTransactions) {
84-
System.out.println("- " + transaction.getType() + ": $" +
85-
String.format("%.2f", transaction.getAmount()) + " - " + transaction.getDescription());
86+
System.out.println(
87+
"- "
88+
+ transaction.getType()
89+
+ ": $"
90+
+ String.format("%.2f", transaction.getAmount())
91+
+ " - "
92+
+ transaction.getDescription());
8693
}
8794

8895
System.out.println("\nSavings account transactions:");
8996
var savingsTransactions = bankAtm.getAuditLog().getTransactionsForAccount("SAV001");
9097
for (var transaction : savingsTransactions) {
91-
System.out.println("- " + transaction.getType() + ": $" +
92-
String.format("%.2f", transaction.getAmount()) + " - " + transaction.getDescription());
98+
System.out.println(
99+
"- "
100+
+ transaction.getType()
101+
+ ": $"
102+
+ String.format("%.2f", transaction.getAmount())
103+
+ " - "
104+
+ transaction.getDescription());
93105
}
94106

95107
System.out.println("\n=== Demo Complete ===");

lesson_17/bank/bank_app/src/main/java/com/codedifferently/lesson17/bank/BaseAccount.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ public void withdraw(double amount) {
5050
throw new IllegalStateException("Withdrawal amount must be positive");
5151
}
5252
if (balance < amount) {
53-
throw new InsufficientFundsException("Account does not have enough funds for withdrawal");
53+
throw new InsufficientFundsException(
54+
"Account does not have enough funds for withdrawal");
5455
}
5556
balance -= amount;
5657
}

lesson_17/bank/bank_app/src/main/java/com/codedifferently/lesson17/bank/BusinessCheckingAccount.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ public class BusinessCheckingAccount extends CheckingAccount {
1515
* @param initialBalance The initial balance of the account.
1616
* @throws IllegalArgumentException If no business owners are provided.
1717
*/
18-
public BusinessCheckingAccount(String accountNumber, Set<Customer> owners, double initialBalance) {
18+
public BusinessCheckingAccount(
19+
String accountNumber, Set<Customer> owners, double initialBalance) {
1920
super(accountNumber, owners, initialBalance);
2021
validateBusinessOwnership(owners);
2122
}

lesson_17/bank/bank_app/src/main/java/com/codedifferently/lesson17/bank/CurrencyConverter.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ public static double convertToUSD(double amount, Currency fromCurrency) {
1313
if (amount < 0) {
1414
throw new IllegalArgumentException("Amount must be positive");
1515
}
16-
return fromCurrency == Currency.USD ? amount : amount / fromCurrency.getConversionRateToUSD();
16+
return fromCurrency == Currency.USD
17+
? amount
18+
: amount / fromCurrency.getConversionRateToUSD();
1719
}
1820
}

lesson_17/bank/bank_app/src/main/java/com/codedifferently/lesson17/bank/SavingsAccount.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
import java.util.Set;
44

55
/**
6-
* Represents a savings account that works like a checking account but doesn't allow check writing.
6+
* Represents a savings account that works like a checking account but doesn't allow check
7+
* writing.
78
*/
89
public class SavingsAccount extends BaseAccount {
910

0 commit comments

Comments
 (0)