package org.mxchange.addressbook.client;\r
\r
import org.mxchange.addressbook.FrameworkInterface;\r
+import org.mxchange.addressbook.contact.Contact;\r
import org.mxchange.addressbook.menu.item.SelectableMenuItem;\r
\r
/**\r
*/\r
public interface Client extends FrameworkInterface {\r
\r
+ /**\r
+ * Displays a "box" for the address\r
+ *\r
+ * @param contact Contact to show address from\r
+ */\r
+ public void displayAddressBox (final Contact contact);\r
+\r
/**\r
* Displays a message to the user\r
+ *\r
* @param message Message to show to the user\r
*/\r
public void displayMessage (final String message);\r
\r
+ /**\r
+ * Displays a "box" for the name\r
+ *\r
+ * @param contact Contact to show name from\r
+ */\r
+ public void displayNameBox (final Contact contact);\r
+\r
+ /**\r
+ * Displays a "box" for other data\r
+ *\r
+ * @param contact Contact to show other data from\r
+ */\r
+ public void displayOtherDataBox (final Contact contact);\r
+\r
/**\r
* Asks the user for a choice and proceeds accordingly\r
* @throws java.lang.Exception\r
import org.mxchange.addressbook.application.Application;\r
import org.mxchange.addressbook.client.BaseClient;\r
import org.mxchange.addressbook.client.Client;\r
+import org.mxchange.addressbook.contact.Contact;\r
import org.mxchange.addressbook.menu.Menu;\r
import org.mxchange.addressbook.menu.MenuTools;\r
import org.mxchange.addressbook.menu.console.ConsoleMenu;\r
this.fillConsoleMenuMap();\r
}\r
\r
+ /**\r
+ * Displays a textual address "box" of given contact\r
+ *\r
+ * @param contact Contact to show address for\r
+ * @todo Use mask\r
+ */\r
+ @Override\r
+ public void displayAddressBox (final Contact contact) {\r
+ // Simple display ...\r
+ // @todo Use mask\r
+ this.displayMessage("Strasse, PLZ Ort, Land: " + contact.getStreet() + "\n" + contact.getZipCode() + " " + contact.getCity() + "\n" + contact.getCountryCode());\r
+ }\r
+\r
/**\r
* Displays textural message to the user\r
* @param message \r
System.out.println(message);\r
}\r
\r
+ /**\r
+ * Displays a textual name "box" of given contact\r
+ *\r
+ * @param contact Contact to show name for\r
+ */\r
+ @Override\r
+ public void displayNameBox (final Contact contact) {\r
+ // Get translated gender as the user may want to see "Mr.", "Mrs."\r
+ String gender = contact.getTranslatedGender();\r
+\r
+ // Get company name\r
+ String companyName = contact.getCompanyName();\r
+\r
+ // If it is empty/null, then assume private contact\r
+ if ((companyName == null) || (companyName.isEmpty())) {\r
+ // Now put all together: gender, surname, family name\r
+ // @todo Use mask\r
+ this.displayMessage("Anrede, Vorname, Name: " + gender + " " + contact.getSurname() + " " + contact.getFamilyName());\r
+ } else {\r
+ // Company contact\r
+ this.displayMessage("Firma: " + companyName + "\nAnsprechpartner: " + gender + " " + contact.getSurname() + " " + contact.getFamilyName());\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Displays a textual other data "box" of given contact\r
+ *\r
+ * @param contact Contact to show other data for\r
+ */\r
+ @Override\r
+ public void displayOtherDataBox (final Contact contact) {\r
+ // Cellphone and such ...\r
+ this.displayMessage("Telefonnumer: " + contact.getPhoneNumber() + "\nFaxnummer: " + contact.getFaxNumber() + "\nHandy: " + contact.getCellphoneNumber() + "\nKommentar:\n" + contact.getComment());\r
+ }\r
+\r
@Override\r
public void doUserChoice () throws Exception {\r
// Get all access keys from menu\r
package org.mxchange.addressbook.contact;\r
\r
import org.mxchange.addressbook.BaseFrameworkSystem;\r
+import org.mxchange.addressbook.client.Client;\r
\r
/**\r
* A general contact\r
this.surname = surname;\r
}\r
\r
+ /**\r
+ * Some "getter" for a translated/human-readable gender\r
+ * @return gender Human-readable gender\r
+ */\r
+ public String getTranslatedGender () {\r
+ // Default init\r
+ String translated = null;\r
+\r
+ // "Translate" it\r
+ switch (this.getGender()) {\r
+ case 'M': // Mr.\r
+ translated = "Herr";\r
+ break;\r
+\r
+ case 'F': // Mrs.\r
+ translated = "Frau";\r
+ break;\r
+\r
+ case 'C': // "Company"\r
+ translated = "Firma";\r
+ break;\r
+\r
+ default: // Unsupported\r
+ this.getLogger().error("Gender " + this.getGender() + " not supported.");\r
+ break;\r
+ }\r
+\r
+ // Return it\r
+ return translated;\r
+ }\r
+\r
/**\r
* ZIP code\r
*\r
public boolean isOwnContact () {\r
return this.ownContact;\r
}\r
+\r
+ /**\r
+ * Shows this contact to the user\r
+ *\r
+ * @param client Client instance to use\r
+ */\r
+ public void show (final Client client) {\r
+ // Display name "box"\r
+ client.displayNameBox((Contact) this);\r
+\r
+ // Display address "box"\r
+ client.displayAddressBox((Contact) this);\r
+\r
+ // Display other data "box"\r
+ client.displayOtherDataBox((Contact) this);\r
+ }\r
}\r
package org.mxchange.addressbook.contact;\r
\r
import org.mxchange.addressbook.FrameworkInterface;\r
+import org.mxchange.addressbook.client.Client;\r
\r
/**\r
*\r
*/\r
public void enableFlagOwnContact ();\r
\r
+ /**\r
+ * Some "getter" for translated gender of the contact\r
+ * @return Translated / human-readable gender\r
+ */\r
+ public String getTranslatedGender ();\r
+\r
/**\r
* Checks whether the contact is user's own data\r
*\r
* @return the comment\r
*/\r
public String getComment ();\r
+\r
+ /**\r
+ * Shows the contact to the user\r
+ *\r
+ * @param client Client instance to call back\r
+ */\r
+ public void show (final Client client);\r
}\r
// It must be found\r
assert(contact instanceof Contact);\r
\r
+ // Display contact\r
+ contact.show(this.getClient());\r
+\r
// @TODO Unfinished\r
throw new UnsupportedOperationException("Method is not finished.");\r
}\r