]> git.mxchange.org Git - jfinancials-lib.git/blobdiff - Addressbook/src/org/mxchange/addressbook/client/BaseClient.java
Convention applied:
[jfinancials-lib.git] / Addressbook / src / org / mxchange / addressbook / client / BaseClient.java
index 09c7b0fe865c26c2dc267d49be4195902630d121..706229c3036de3a5c9089f01a547a4f7a2d936ef 100644 (file)
 package org.mxchange.addressbook.client;\r
 \r
 import org.mxchange.addressbook.BaseFrameworkSystem;\r
+import org.mxchange.addressbook.menu.Menu;\r
 \r
 /**\r
  * A general client\r
  *\r
  * @author Roland Haeder\r
  */\r
-public class BaseClient extends BaseFrameworkSystem {\r
+public abstract class BaseClient extends BaseFrameworkSystem {\r
 \r
     /**\r
      * Current menu choice\r
@@ -49,12 +50,16 @@ public class BaseClient extends BaseFrameworkSystem {
        this.isRunning = false;\r
     }\r
 \r
+    /**\r
+     * Enables the client\r
+     */\r
     public void enableIsRunning () {\r
        this.isRunning = true;\r
     }\r
 \r
     /**\r
      * Current menu choice\r
+     * \r
      * @return the currentMenu\r
      */\r
     public String getCurrentMenu () {\r
@@ -69,8 +74,41 @@ public class BaseClient extends BaseFrameworkSystem {
        this.currentMenu = currentMenu;\r
     }\r
 \r
-    public boolean isApplicationRunning () {\r
+    /**\r
+     * Some kind of "getter" for a Menu instance from given menu type\r
+     *\r
+     * @param menuType Menu type, e.g. "main" for main menu\r
+     * @return\r
+     */\r
+    public abstract Menu getMenu (final String menuType);\r
+\r
+    /**\r
+     * Determines whether the application is still active by checking some\r
+     * conditions\r
+     * \r
+     * @return Whether the application is still active\r
+     */\r
+    public boolean isRunning () {\r
        // In console client, 0 may have been used\r
        return this.isRunning;\r
     }\r
+\r
+    /**\r
+     * Shows given menu\r
+     *\r
+     * @param menuType Given menu to show\r
+     */\r
+    protected void showMenu (final String menuType) {\r
+       Menu menu = this.getMenu(menuType);\r
+       \r
+       // Is the menu set?\r
+       if (!(menu instanceof Menu)) {\r
+           // Not found\r
+           // @todo Own exception?\r
+           throw new NullPointerException("Menu '" + menuType + "' not found.");\r
+       }\r
+       \r
+       // Show menu\r
+       menu.show((Client) this);\r
+    }\r
 }\r