title: Gender Field in java
body: <p>I'm creating an Employee class containing three fields: name, age, and gender. I need to create a gender field but the user can only choose male or female. I guess I have to do this in a boolean form but I don't know how I'm going to do that. Can anyone help me out?</p>
  
  <p>So far I have:</p>
  
  <pre><code>public class Employee {
  
  private String name;
  private int age;
  private boolean gender;
  private boolean male;
  private boolean female;
  
  public Employee(String name, int age, boolean gender) 
  {
      this.name = name;
      this.age = age;
  
      boolean f = female;
      boolean m = male;
  
      if (gender = f)
      {
          System.out.print("female");
      }
  
      else if (gender = m)
      {
          System.out.print("male");
      }
  }
  
  public String getName() {
      return name;
  }
  
  public void setName(String name) {
      this.name = name;
  }
  
  public int getAge() {
      return age;
  }
  
  public void setAge(int age) {
      this.age = age;
  }
  
  public boolean isGender() {
      return gender;
  }
  
  public void setGender(boolean gender) 
  {
      if (gender = f)
      {
          System.out.print("female");
      }
  
      else if (gender = m)
      {
          System.out.print("male");
      }
  }
  }
  </code></pre>