]> git.mxchange.org Git - jbonuscard-lib.git/commitdiff
Introduced Gender enum which replaces the old char
authorRoland Haeder <roland@mxchange.org>
Mon, 27 Jul 2015 10:55:18 +0000 (12:55 +0200)
committerRoland Haeder <roland@mxchange.org>
Mon, 27 Jul 2015 10:55:18 +0000 (12:55 +0200)
Signed-off-by:Roland Häder <roland@mxchange.org>

14 files changed:
Addressbook/src/org/mxchange/addressbook/client/Client.java
Addressbook/src/org/mxchange/addressbook/client/console/ConsoleClient.java
Addressbook/src/org/mxchange/addressbook/client/gui/AddressbookFrame.java
Addressbook/src/org/mxchange/addressbook/client/gui/SwingClient.java
Addressbook/src/org/mxchange/addressbook/contact/BaseContact.java
Addressbook/src/org/mxchange/addressbook/contact/Contact.java
Addressbook/src/org/mxchange/addressbook/contact/Gender.java [new file with mode: 0644]
Addressbook/src/org/mxchange/addressbook/contact/user/UserContact.java
Addressbook/src/org/mxchange/addressbook/database/backend/csv/CsvDatabaseBackend.java
Addressbook/src/org/mxchange/addressbook/localization/bundle_de_DE.properties
Addressbook/src/org/mxchange/addressbook/localization/bundle_en_US.properties
Addressbook/src/org/mxchange/addressbook/manager/contact/ContactManager.java
Addressbook/src/org/mxchange/addressbook/manager/contact/ManageableContact.java
Addressbook/src/org/mxchange/addressbook/model/gender/GenderComboBoxModel.java [deleted file]

index 7dcbdfe4a629889f6b6b696653fa7120a6a1a5d8..9ebbc14c79b1547bea2ed702a1790d9a74703f5d 100644 (file)
@@ -19,6 +19,7 @@ package org.mxchange.addressbook.client;
 import org.mxchange.addressbook.FrameworkInterface;
 import org.mxchange.addressbook.exceptions.UnhandledUserChoiceException;
 import org.mxchange.addressbook.contact.Contact;
+import org.mxchange.addressbook.contact.Gender;
 import org.mxchange.addressbook.menu.item.SelectableMenuItem;
 
 /**
@@ -68,6 +69,14 @@ public interface Client extends FrameworkInterface {
         */
        public void doShutdown ();
 
+       /**
+        * Asks the user to enter his/her gender (M=Male, F=Female, C=Company)
+        * 
+        * @param message Message to output
+        * @return Gender enum
+        */
+       public Gender enterGender (final String message);
+
        /**
         * Displays a message to the user
         *
index 94818f13d145b60ef3f2520a3a0d2e68fe0f85c8..b018096e7267131e7d384ed1ccddc4c4c5b3b687 100644 (file)
@@ -24,6 +24,7 @@ import org.mxchange.addressbook.application.Application;
 import org.mxchange.addressbook.client.BaseClient;
 import org.mxchange.addressbook.client.Client;
 import org.mxchange.addressbook.contact.Contact;
+import org.mxchange.addressbook.contact.Gender;
 import org.mxchange.addressbook.contact.user.UserContact;
 import org.mxchange.addressbook.exceptions.UnhandledUserChoiceException;
 import org.mxchange.addressbook.menu.Menu;
@@ -138,7 +139,7 @@ public class ConsoleClient extends BaseClient implements Client {
                }
 
                // Gender:
-               char gender = this.getContactManager().enterOwnGender();
+               Gender gender = this.getContactManager().enterOwnGender();
 
                // Surname
                String surname = this.getContactManager().enterOwnSurname();
@@ -183,7 +184,7 @@ public class ConsoleClient extends BaseClient implements Client {
        @Override
        public Contact doEnterOwnData () {
                // First ask for gender
-               char gender = this.getContactManager().enterOwnGender();
+               Gender gender = this.getContactManager().enterOwnGender();
 
                // 2nd for surname
                String surname = this.getContactManager().enterOwnSurname();
@@ -287,6 +288,30 @@ public class ConsoleClient extends BaseClient implements Client {
                return input;
        }
 
+       /**
+        * Asks the user to enter his/her gender
+        * 
+        * @param message Message to the user
+        * @return Gender enum
+        */
+       @Override
+       public Gender enterGender (final String message) {
+               // Get valid chars
+               char[] validChars = Gender.validChars();
+
+               // Debug message
+               //* NOISY-DEBUG: */ System.out.println(validChars);
+
+               // Call inner method
+               char gender = this.enterChar(validChars, message);
+
+               // Now get a Gender instance back
+               Gender g = Gender.fromChar(gender);
+
+               // Return it
+               return g;
+       }
+
        /**
         * Reads an integer (int) with a textural message from the user
         *
index 2c9494ba812137d68af8c272ef71db5380a245dc..b3bcab4c964c6d34e98535990ca827405e37308e 100644 (file)
@@ -16,7 +16,6 @@
  */
 package org.mxchange.addressbook.client.gui;
 
-import org.mxchange.addressbook.model.gender.GenderComboBoxModel;
 import java.awt.BorderLayout;
 import java.awt.GridLayout;
 import java.awt.event.ActionEvent;
@@ -28,6 +27,7 @@ import java.awt.event.WindowEvent;
 import java.text.MessageFormat;
 import javax.swing.BorderFactory;
 import javax.swing.BoxLayout;
+import javax.swing.DefaultComboBoxModel;
 import javax.swing.JComboBox;
 import javax.swing.JDialog;
 import javax.swing.JFrame;
@@ -38,11 +38,13 @@ import javax.swing.JMenuItem;
 import javax.swing.JPanel;
 import javax.swing.JScrollPane;
 import javax.swing.JTable;
+import javax.swing.JTextField;
 import javax.swing.border.TitledBorder;
 import javax.swing.table.TableModel;
 import org.mxchange.addressbook.BaseFrameworkSystem;
 import org.mxchange.addressbook.application.AddressbookApplication;
 import org.mxchange.addressbook.client.Client;
+import org.mxchange.addressbook.contact.Gender;
 import org.mxchange.addressbook.exceptions.FrameAlreadyInitializedException;
 import org.mxchange.addressbook.model.contact.ContactTableModel;
 
@@ -281,17 +283,54 @@ public class AddressbookFrame extends BaseFrameworkSystem implements ClientFrame
                
                // Init 3 panels:
                // 1) Panel "name" input boxes
-               JPanel panel = new JPanel();
-               panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
+               JPanel namePanel = new JPanel();
+               namePanel.setLayout(new BoxLayout(namePanel, BoxLayout.Y_AXIS));
                
                // Set border to titled version
-               panel.setBorder(new TitledBorder(this.generateBorderTitle("name")));
+               namePanel.setBorder(new TitledBorder(this.generateBorderTitle("name")));
 
                // Add some input boxes for "name" panel
-               JComboBox<String> gender = new JComboBox<>(new GenderComboBoxModel(this.getClient()));
+               JComboBox<Gender> gender = new JComboBox<>(new DefaultComboBoxModel<Gender>());
+
+               // Panel for gender
+               JPanel gPanel = new JPanel();
+               gPanel.setLayout(new GridLayout(1, 2));
+
+               // Set tooltip text
+               gPanel.setToolTipText(this.getBundle().getString("AddressbookFrame.gender.tooltipText"));
+
+               // Gender text field
+               JLabel gLabel = new JLabel(this.getBundle().getString("AddressbookFrame.gender.text"));
+
+               // Add both to gender panel
+               gPanel.add(gLabel);
+               gPanel.add(gender);
+
+               // Add panel to north of "name" panel
+               namePanel.add(gPanel, BorderLayout.NORTH);
+
+               // Panel for surname
+               JPanel sPanel = new JPanel();
+               sPanel.setLayout(new GridLayout(1, 2));
+
+               // Set too tip text
+               sPanel.setToolTipText(this.getBundle().getString("AddressbookFrame.surname.tooltipText"));
+
+               // New label for surname is not needed
+               JLabel sLabel = new JLabel(this.getBundle().getString("AddressbookFrame.surname.text"));
+
+               // And input box
+               JTextField surname = new JTextField(20);
+
+               // Add both to surname panel
+               sPanel.add(sLabel);
+               sPanel.add(surname);
+
+               // Add surname panel to "name" panel
+               namePanel.add(sPanel, BorderLayout.CENTER);
 
                // Finally add panel to dialog
-               this.addContact.add(panel);
+               this.addContact.add(namePanel);
                
                // Only for developing:
                /* DEBUG: */ this.addContact.setVisible(true);
index a9ba1c1fdc1454cb5f24d17cbe93c51e89f4c6ba..634b0cf2cf4cca5c1bad26da82e637102ac59517 100644 (file)
@@ -20,6 +20,7 @@ import org.mxchange.addressbook.application.Application;
 import org.mxchange.addressbook.client.BaseClient;
 import org.mxchange.addressbook.client.Client;
 import org.mxchange.addressbook.contact.Contact;
+import org.mxchange.addressbook.contact.Gender;
 import org.mxchange.addressbook.exceptions.FrameAlreadyInitializedException;
 import org.mxchange.addressbook.exceptions.UnhandledUserChoiceException;
 import org.mxchange.addressbook.menu.Menu;
@@ -126,6 +127,11 @@ public class SwingClient extends BaseClient implements Client {
                throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }
 
+       @Override
+       public Gender enterGender (final String message) {
+               throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+       }
+
        @Override
        public int enterInt (final int minimum, final int maximum, final String message) {
                throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
index f03a3c1bdf20c1ded94ccacfb5eb68ceeefbb4d0..aa82551e7b7fbf62a73382ed5acd107c4313afa0 100644 (file)
@@ -75,10 +75,9 @@ public class BaseContact extends BaseFrameworkSystem {
        private String faxNumber;
 
        /**
-        * Gender code of the contact: - M = Mr. (male) - F = Mrs. (female) - C =
-        * Company
+        * Gender instance
         */
-       private char gender;
+       private Gender gender;
 
        /**
         * House number
@@ -139,7 +138,7 @@ public class BaseContact extends BaseFrameworkSystem {
                Contact contact = (Contact) object;
 
                // Now test some data @todo Definedly needs improvement
-               return ((this.getGender() == contact.getGender())
+               return ((this.getGender().equals(contact.getGender()))
                                && (this.getSurname().toLowerCase().equals(contact.getSurname().toLowerCase()))
                                && (this.getFamilyName().toLowerCase().equals(contact.getFamilyName().toLowerCase())));
        }
@@ -244,7 +243,7 @@ public class BaseContact extends BaseFrameworkSystem {
                String csvString = String.format(
                                "\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\";\"%s\"\n",
                                this.isOwnContact(),
-                               this.getGender(),
+                               this.getGender().getDatabaseValue(),
                                this.getSurname(),
                                this.getFamilyName(),
                                this.getCompanyName(),
@@ -323,7 +322,7 @@ public class BaseContact extends BaseFrameworkSystem {
         *
         * @return the gender
         */
-       public char getGender () {
+       public Gender getGender () {
                return this.gender;
        }
 
@@ -332,7 +331,7 @@ public class BaseContact extends BaseFrameworkSystem {
         *
         * @param gender the gender to set
         */
-       private void setGender (final char gender) {
+       private void setGender (final Gender gender) {
                this.gender = gender;
        }
 
@@ -392,15 +391,15 @@ public class BaseContact extends BaseFrameworkSystem {
 
                // "Translate" it
                switch (this.getGender()) {
-                       case 'M': // Mr.
+                       case MALE: // Mr.
                                translated = "Herr";
                                break;
 
-                       case 'F': // Mrs.
+                       case FEMALE: // Mrs.
                                translated = "Frau";
                                break;
 
-                       case 'C': // "Company"
+                       case COMPANY: // "Company"
                                translated = "Firma";
                                break;
 
@@ -435,7 +434,7 @@ public class BaseContact extends BaseFrameworkSystem {
        public int hashCode () {
                int hash = 7;
                hash = 79 * hash + Objects.hashCode(this.getFamilyName());
-               hash = 79 * hash + this.getGender();
+               hash = 79 * hash + this.getGender().hashCode();
                hash = 79 * hash + Objects.hashCode(this.getSurname());
                return hash;
        }
@@ -497,9 +496,10 @@ public class BaseContact extends BaseFrameworkSystem {
         * @param familyName Family name
         * @param companyName Company name
         */
-       public void updateNameData (final char gender, final String surname, final String familyName, final String companyName) {
+       public void updateNameData (final Gender gender, final String surname, final String familyName, final String companyName) {
                // Set all
                this.setGender(gender);
+
                if (surname != null) {
                        this.setSurname(surname);
                }
index 76230fbdd5b2124bdbad18e89ca3bb902bf53c4d..57bca671d9ce38d0ede711a0306a326331d51b62 100644 (file)
@@ -44,7 +44,7 @@ public interface Contact extends FrameworkInterface {
         *
         * @return the gender
         */
-       public char getGender ();
+       public Gender getGender ();
 
        /**
         * Surname
@@ -169,7 +169,7 @@ public interface Contact extends FrameworkInterface {
         * @param familyName Family name
         * @param companyName Company name
         */
-       public void updateNameData (final char gender, final String surname, final String familyName, final String companyName);
+       public void updateNameData (final Gender gender, final String surname, final String familyName, final String companyName);
 
        /**
         * Updates other data in this Contact instance
diff --git a/Addressbook/src/org/mxchange/addressbook/contact/Gender.java b/Addressbook/src/org/mxchange/addressbook/contact/Gender.java
new file mode 100644 (file)
index 0000000..96bce2c
--- /dev/null
@@ -0,0 +1,168 @@
+/*
+ * Copyright (C) 2015 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.addressbook.contact;
+
+/**
+ * Gender enum
+ * @author Roland Haeder
+ */
+public enum Gender {
+       /**
+        * Unknown enum
+        */
+       UNKNOWN("U", "BaseContact.gender.unknown.text"),
+
+       /**
+        * Male enum
+        */
+       MALE("M", "BaseContact.gender.male.text"),
+
+       /**
+        * Female enum
+        */
+       FEMALE("F", "BaseContact.gender.female.text"),
+
+       /**
+        * Company enum
+        */
+       COMPANY("C", "BaseContact.gender.company.text");
+
+       /**
+        * Cache for valid chars
+        */
+       private static char[] validChars;
+
+       /**
+        * Getter for Gender enum from given character
+        *
+        * @param gender Gender character
+        * @return Gender enum
+        */
+       public static Gender fromChar (final char gender) {
+               Gender g = null;
+               switch (gender) {
+                       case 'U': // Unknown
+                               g = UNKNOWN;
+                               break;
+
+                       case 'M': // Male
+                               g = MALE;
+                               break;
+
+                       case 'F': // Female
+                               g = FEMALE;
+                               break;
+
+                       case 'C': // Company
+                               g = COMPANY;
+                               break;
+
+                       default: // Unsupported
+                               throw new IllegalArgumentException("gender " + gender + " is invalid.");
+               }
+
+               // Return it
+               return g;
+       }
+
+       /**
+        * Valid chars
+        * 
+        * @return Valid chars
+        */
+       public static char[] validChars () {
+               // Is cache set?
+               if (validChars != null) {
+                       // Return it
+                       return validChars;
+               }
+
+               // Init array
+               char[] valid = new char[3];
+
+               // Get values
+               int i = 0;
+               for (Object value : values()) {
+                       // First cast
+                       Gender gender = (Gender) value;
+
+                       // Debug message
+                       //* NOISY-DEBUG: */ System.out.println("gender=" + gender);
+
+                       // Is it "U"?
+                       if (gender.getDatabaseValue().equals("U")) {
+                               // Skip this
+                               continue;
+                       }
+
+                       // Debug message
+                       //* NOISY-DEBUG: */ System.out.println(MessageFormat.format("gender={0} - adding at pos {1} ...", gender, i));
+
+                       // Get database value as this is also the access
+                       valid[i] = gender.getDatabaseValue().charAt(0);
+
+                       // Increment index
+                       i++;
+               }
+
+               // Set it here
+               validChars = valid;
+
+               // Return finialized array
+               return valid;
+       }
+
+       /**
+        * Database value
+        */
+       private final String databaseValue;
+
+       /**
+        * Output value (for messages)
+        */
+       private final String messageKey;
+
+       /**
+        * Constructor
+        * 
+        * @param databaseValue Value being stored in database
+        * @param messageKey Message key for resource file
+        */
+       private Gender (final String databaseValue, final String messageKey) {
+               // Set both
+               this.databaseValue = databaseValue;
+               this.messageKey = messageKey;
+       }
+
+       /**
+        * Database value
+        * 
+        * @return the databaseValue
+        */
+       protected String getDatabaseValue () {
+               return this.databaseValue;
+       }
+
+       /**
+        * Output value (for messages)
+        * 
+        * @return the messageKey
+        */
+       protected String getMessageKey () {
+               return this.messageKey;
+       }
+}
index 5a530b0bfe9b40b87c77e1e0c54e4a7a2fccd552..fd6637e1d05fbdd041b30c6585461da13e36a184 100644 (file)
@@ -17,6 +17,7 @@
 package org.mxchange.addressbook.contact.user;
 
 import org.mxchange.addressbook.contact.Contact;
+import org.mxchange.addressbook.contact.Gender;
 import org.mxchange.addressbook.contact.book.BookContact;
 import org.mxchange.addressbook.database.storage.csv.StoreableCsv;
 
@@ -37,7 +38,7 @@ public class UserContact extends BookContact implements Contact, StoreableCsv {
         * @param companyName Company name
         * @todo Add validation of data
         */
-       public UserContact (final char gender, final String surname, final String familyName, final String companyName) {
+       public UserContact (final Gender gender, final String surname, final String familyName, final String companyName) {
                // Make sure all constructors are called
                this();
 
index bc7e001eb44ee7f6201d2ae17c8dbccb72ba3923..3abb9da8c3a6511a4795d3bb1bfc87baa45b1d21 100644 (file)
@@ -26,6 +26,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.StringTokenizer;
 import org.mxchange.addressbook.contact.Contact;
+import org.mxchange.addressbook.contact.Gender;
 import org.mxchange.addressbook.contact.book.BookContact;
 import org.mxchange.addressbook.contact.user.UserContact;
 import org.mxchange.addressbook.database.backend.BaseDatabaseBackend;
@@ -307,7 +308,7 @@ public class CsvDatabaseBackend extends BaseDatabaseBackend implements CsvBacken
                                String strData = strippedToken;
                                Long num = null;
                                Boolean bool = null;
-                               char gender = '?';
+                               Gender gender = null;
 
                                // Now, let's try a number check, if no null
                                if (strippedToken != null) {
@@ -335,7 +336,8 @@ public class CsvDatabaseBackend extends BaseDatabaseBackend implements CsvBacken
                                // Now, let's try a boolean check, if no null
                                if ((strippedToken != null) && (num == null) && (bool == null) && ((strippedToken.equals("M")) || (strippedToken.equals("F")) || (strippedToken.equals("C")))) {
                                        // Get first character
-                                       gender = strippedToken.charAt(0);
+                                       //gender = strippedToken.charAt(0);
+                                       throw new UnsupportedOperationException("Gender dection is unifnished!");
                                }
 
                                // Now it depends on the counter which position we need to check
@@ -364,7 +366,6 @@ public class CsvDatabaseBackend extends BaseDatabaseBackend implements CsvBacken
 
                                        case 1: // Gender
                                                assert (contact instanceof Contact) : "First token was not boolean";
-                                               assert (gender != '?') : "Gender is not detected.";
 
                                                // Update data
                                                contact.updateNameData(gender, null, null, null);
@@ -372,7 +373,6 @@ public class CsvDatabaseBackend extends BaseDatabaseBackend implements CsvBacken
 
                                        case 2: // Surname
                                                assert (contact instanceof Contact) : "First token was not boolean";
-                                               assert (gender != '?') : "Gender is not detected.";
 
                                                // Update data
                                                contact.updateNameData(gender, strippedToken, null, null);
@@ -380,7 +380,6 @@ public class CsvDatabaseBackend extends BaseDatabaseBackend implements CsvBacken
 
                                        case 3: // Family name
                                                assert (contact instanceof Contact) : "First token was not boolean";
-                                               assert (gender != '?') : "Gender is not detected.";
 
                                                // Update data
                                                contact.updateNameData(gender, null, strippedToken, null);
@@ -388,7 +387,6 @@ public class CsvDatabaseBackend extends BaseDatabaseBackend implements CsvBacken
 
                                        case 4: // Company name
                                                assert (contact instanceof Contact) : "First token was not boolean";
-                                               assert (gender != '?') : "Gender is not detected.";
 
                                                // Update data
                                                contact.updateNameData(gender, null, null, strippedToken);
index f873060b7d749199cad392b7d8ef6cb7f7eeb780..7cc24c1ce0add1687576b540241e23f2336e4e9e 100644 (file)
@@ -27,6 +27,14 @@ AddressbookFrame.menuItem.editOwnData.toolTipText=Erlaubt das \u00c4ndern eigene
 AddressbookFrame.dialog.addContact.title.text=Neue Adresse hinzuf\u00fcgen
 AddressbookFrame.main.title.text=Adressen auflisten
 AddressbookFrame.border.name.title.text=Anrede, Vorname, Nachname
+AddressbookFrame.gender.text=Anrede:
+AddressbookFrame.gender.tooltipText=W\u00e4hlen Sie die Anrede aus.
+AddressbookFrame.surname.text=Vorname:
+AddressbookFrame.surname.tooltipText=Geben Sie den Vornamen ein.
+BaseContact.gender.unknown.text=Unbekannt
+BaseContact.gender.male.text=Herr
+BaseContact.gender.female.text=Frau
+BaseContact.gender.company.text=Firma
 ContactManager.columnName.gender.text=Anrede
 ContactManager.columnName.surname.text=Vorname
 ContactManager.columnName.familyName.text=Nachname
index 46addd1d7f197c7500286f8f95a830d2d128cd66..8fce7b594c85918175e8c32dfe733817627f552e 100644 (file)
@@ -26,6 +26,14 @@ AddressbookFrame.menuItem.editOwnData.text=Edit own data
 AddressbookFrame.menuItem.editOwnData.toolTipText=Allows the user to edit own address data
 AddressbookFrame.dialog.addContact.title.text=Add new address
 AddressbookFrame.main.title.text=List addresses
+AddressbookFrame.gender.text=Gender:
+AddressbookFrame.gender.tooltipText=Choose gender.
+AddressbookFrame.surname.text=Surname:
+AddressbookFrame.surname.tooltipText=Enter surname.
+BaseContact.gender.unknown.text=Unknown
+BaseContact.gender.male.text=Mr.
+BaseContact.gender.female.text=Mrs.
+BaseContact.gender.company.text=Company
 ContactManager.columnName.gender.text=Gender
 ContactManager.columnName.surname.text=Surname
 ContactManager.columnName.familyName.text=Family name
index f14525f6c08a783730767dc3fb6030d50fddd70b..107bf3f1acfa24bfbe973571004fc40c015bf5f0 100644 (file)
@@ -23,6 +23,7 @@ import java.util.Iterator;
 import java.util.List;
 import org.mxchange.addressbook.client.Client;
 import org.mxchange.addressbook.contact.Contact;
+import org.mxchange.addressbook.contact.Gender;
 import org.mxchange.addressbook.database.frontend.contact.ContactDatabaseFrontend;
 import org.mxchange.addressbook.database.frontend.contact.ContactWrapper;
 import org.mxchange.addressbook.exceptions.UnhandledUserChoiceException;
@@ -345,8 +346,8 @@ public class ContactManager extends BaseManager implements ManageableContact {
         * @return Gender of the user
         */
        @Override
-       public char enterOwnGender () {
-               return this.getClient().enterChar(new char[] {'M', 'F', 'C'}, "Bitte geben Sie die Anrede ein: (M=Herr, F=Frau, C=Firma): ");
+       public Gender enterOwnGender () {
+               return this.getClient().enterGender("Bitte geben Sie die Anrede ein: (M=Herr, F=Frau, C=Firma): ");
        }
 
        /**
index 869f3e2ac4a554fbe7bee325df434353ccaba8d7..2ed123c2ee6592afab633406d6802feb896c0f7f 100644 (file)
@@ -19,6 +19,7 @@ package org.mxchange.addressbook.manager.contact;
 import java.util.List;
 import org.mxchange.addressbook.client.Client;
 import org.mxchange.addressbook.contact.Contact;
+import org.mxchange.addressbook.contact.Gender;
 import org.mxchange.addressbook.manager.Manageable;
 
 /**
@@ -93,7 +94,7 @@ public interface ManageableContact extends Manageable {
         *
         * @return Gender
         */
-       public char enterOwnGender ();
+       public Gender enterOwnGender ();
 
        /**
         * Allows the user to enter own phone number.
diff --git a/Addressbook/src/org/mxchange/addressbook/model/gender/GenderComboBoxModel.java b/Addressbook/src/org/mxchange/addressbook/model/gender/GenderComboBoxModel.java
deleted file mode 100644 (file)
index 0b0a46d..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (C) 2015 Roland Haeder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.addressbook.model.gender;
-
-import javax.swing.ComboBoxModel;
-import org.mxchange.addressbook.client.Client;
-import org.mxchange.addressbook.model.BaseModel;
-
-/**
- *
- * @author Roland Haeder
- */
-public class GenderComboBoxModel extends BaseModel implements ComboBoxModel<String> {
-
-       /**
-        * Selected item instance, the value can only be 'M', 'F' or 'C'
-        */
-       private char selectedItem = 0;
-
-       /**
-        * Selectable items
-        */
-       private final char[] validItems = new char[] {'M', 'F', 'C'};
-
-       /**
-        * Creates an instance of this model with a Client instance
-        * @param client Client instance
-        */
-       public GenderComboBoxModel (final Client client) {
-               // Call super constructor
-               super();
-
-               // Set client
-               this.setClient(client);
-       }
-
-       @Override
-       public String getElementAt (final int index) {
-               // Return it
-               return String.valueOf(this.validItems[index]);
-       }
-
-       /**
-        * Gets the currently selected item or null if nothing is selected.
-        * 
-        * @return Selected item or null
-        */
-       @Override
-       public Object getSelectedItem () {
-               // Is the char set other than 0?
-               if (this.selectedItem == 0) {
-                       // Nothing selected
-                       return null;
-               }
-
-               // Return string representing the selected item
-               return this.selectedItem;
-       }
-
-       @Override
-       public void setSelectedItem (final Object anItem) {
-               throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
-       }
-
-       /**
-        * Getter for size. Here only 3 values are valid: M, F and C
-        *
-        * @return Maximum size
-        */
-       @Override
-       public int getSize () {
-               // Get size of array
-               return this.validItems.length;
-       }
-}