Through this example, the handling of invalid operations (e.g., mismatched currencies or + * invalid inputs) is demonstrated using custom exceptions. Logging is used for transparency. + * + *
This highlights the practical application of object-oriented principles such as encapsulation + * and validation in a financial context. + */ public class App { // Initialize the logger private static final Logger logger = Logger.getLogger(App.class.getName()); - + /** + * Program entry point. + * + * @param args command line args + */ public static void main(String[] args) { // Create instances of Money Money usdAmount1 = new Money(50.00, "USD"); From 6119a0e858183064762a31ffd15d9fa3baf46eaf Mon Sep 17 00:00:00 2001 From: Ahmed-Taha-981 <122402269+Ahmed-Taha-981@users.noreply.github.com> Date: Mon, 9 Dec 2024 17:12:34 +0200 Subject: [PATCH 6/6] Added a test for App.java --- money/src/test/java/com/iluwater/money/MoneyTest.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/money/src/test/java/com/iluwater/money/MoneyTest.java b/money/src/test/java/com/iluwater/money/MoneyTest.java index 78235370c4ed..94d93359b0ad 100644 --- a/money/src/test/java/com/iluwater/money/MoneyTest.java +++ b/money/src/test/java/com/iluwater/money/MoneyTest.java @@ -5,6 +5,7 @@ import com.iluwatar.CannotAddTwoCurrienciesException; import com.iluwatar.CannotSubtractException; import com.iluwatar.Money; +import com.iluwatar.App; class MoneyTest { @@ -112,4 +113,13 @@ void testExchangeCurrency_NegativeExchangeRate() { money.exchangeCurrency("EUR", -0.85); }); } + + + @Test + void testAppExecution() { + assertDoesNotThrow(() -> { + App.main(new String[]{}); + }, "App execution should not throw any exceptions"); + } + }