| | 1 | | /** |
| | 2 | |
|
| | 3 | | @file CalculatorApp.java |
| | 4 | | @brief This file serves as the main application file for the Calculator App. |
| | 5 | | @details This file contains the entry point of the application, which is the main method. It initializes the necessary c |
| | 6 | | */ |
| | 7 | | /** |
| | 8 | |
|
| | 9 | | @package com.ucoruh.calculator |
| | 10 | | @brief The com.ucoruh.calculator package contains all the classes and files related to the Calculator App. |
| | 11 | | */ |
| | 12 | | package com.ucoruh.calculator; |
| | 13 | |
|
| | 14 | | import java.io.IOException; |
| | 15 | |
|
| | 16 | | import org.slf4j.LoggerFactory; |
| | 17 | |
|
| | 18 | | import ch.qos.logback.classic.Logger; |
| | 19 | |
|
| | 20 | | /** |
| | 21 | | * |
| | 22 | | * @class CalculatorApp |
| | 23 | | * @brief This class represents the main application class for the Calculator |
| | 24 | | * App. |
| | 25 | | * @details The CalculatorApp class provides the entry point for the Calculator |
| | 26 | | * App. It initializes the necessary components, performs calculations, |
| | 27 | | * and handles exceptions. |
| | 28 | | * @author ugur.coruh |
| | 29 | | */ |
| 1 | 30 | | public class CalculatorApp { |
| | 31 | | /** |
| | 32 | | * @brief Logger for the CalculatorApp class. |
| | 33 | | */ |
| 1 | 34 | | private static final Logger logger = (Logger) LoggerFactory.getLogger(CalculatorApp.class); |
| | 35 | |
|
| | 36 | | /** |
| | 37 | | * @brief The main entry point of the Calculator App. |
| | 38 | | * |
| | 39 | | * @details The main method is the starting point of the Calculator App. It |
| | 40 | | * initializes the logger, performs logging, displays a greeting |
| | 41 | | * message, and handles user input. |
| | 42 | | * |
| | 43 | | * @param args The command-line arguments passed to the application. |
| | 44 | | */ |
| | 45 | | public static void main(String[] args) { |
| | 46 | | // Logging messages for informational purposes |
| 1 | 47 | | logger.info("Logging message"); |
| | 48 | | // Logging an error message |
| 1 | 49 | | logger.error("Error message"); |
| | 50 | | // Displaying a greeting message |
| 1 | 51 | | System.out.println("Hello World!"); |
| | 52 | |
|
| | 53 | | try { |
| | 54 | | // Checking if command-line arguments are provided |
| 1 | 55 | | if (args != null) { |
| | 56 | | // Checking if there are any arguments |
| 1 | 57 | | if (args.length > 0) { |
| | 58 | | // Checking if the first argument is "1" |
| 1 | 59 | | if (args[0].equals("1")) { |
| | 60 | | // Throwing a dummy IOException |
| 1 | 61 | | throw new IOException("Dummy Exception..."); |
| | 62 | | } |
| | 63 | | } |
| | 64 | | } |
| | 65 | |
|
| | 66 | | // Prompting the user to press Enter to continue |
| 1 | 67 | | System.out.println("Press Enter to Continue..."); |
| | 68 | | // Reading user input from the console |
| 1 | 69 | | System.in.read(); |
| | 70 | | // Displaying a closing message |
| 1 | 71 | | System.out.println("Thank you..."); |
| 1 | 72 | | } catch (IOException e) { |
| | 73 | | // Logging the exception |
| 1 | 74 | | logger.error(e.toString()); |
| | 75 | | // Printing the exception stack trace |
| 1 | 76 | | e.printStackTrace(); |
| 1 | 77 | | } |
| 1 | 78 | | } |
| | 79 | |
|
| | 80 | | } |