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
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
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