package javakurs.musterloesung.uebung07;

/**
 * {@link Product} is a data structure for articles in the fridge (FCM)
 * implemented in the class {@link Fridge}. A Product is an abstract object
 * containing only it's own name, it's name in the plural form and it's gender.
 *
 * @author Joerg Steffen, DFKI
 * @version $Id: Product.java,v 1.1 2010/12/13 13:15:55 steffen Exp $
 */
public class Product {

  /**
   * This contains the product's name.
   */
  private String name;

  /**
   * This contains the product's gender.
   */
  private String genus;

  /**
   * This contains product's plural word form.
   */
  private String pluralForm;


  /**
   * This creates a new instance of {@link Product}.
   *
   * @param name
   *          the new product's name
   * @param genus
   *          the product's gender
   * @param pluralForm
   *          the plural form of the product's name
   */
  public Product(String name, String genus, String pluralForm) {

    this.name = name;
    this.genus = genus;
    this.pluralForm = pluralForm;
  }


  /**
   * This returns the product's name.
   *
   * @return the name
   */
  protected String getName() {

    return this.name;
  }


  /**
   * This returns the product's genus.
   *
   * @return the genus
   */
  protected String getGenus() {

    return this.genus;
  }


  /**
   * This returns the product's plural word form.
   *
   * @return the plural
   */
  protected String getPluralForm() {

    return this.pluralForm;
  }


  /**
   * This returns a grammatical representation for the given number of this
   * product.
   *
   * @param number
   *          the number
   * @return a string representation of the product
   */
  public String toString(int number) {

    String result = null;

    switch (number) {
      case 0:
        if (this.getGenus().equals("fem")) {
          result = "keine " + this.name;
        }
        else {
          result = "kein " + this.name;
        }
        break;
      case 1:
        if (this.getGenus().equals("fem")) {
          result = "eine " + this.name;
        }
        else {
          result = "ein " + this.name;
        }
        break;
      default:
        result = number + " " + this.pluralForm;
    }

    return result;
  }
}
