title: Object doesn`t return expected value
body: <p>I am learning about <em>factory methods</em> and I tried to write a class using them.  </p>
  
  <pre><code> public enum Animal{  
      DOG(1), CAT(2), PIG(3);  
  
      private int code;
  
      public static Animal dog(){  
      return DOG; }  
      public static Animal cat(){  
      return CAT; }    
      public static Animal pig(){  
      return PIG; } 
  
   public Animal(){  
      switch(this):  
         case DOG: {this.code=1;}  
         case CAT: {this.code=2;}  
         case PIG: {this.code=3;}
   }
  
   public Animal(int i){  
      if(i==1){return DOG;}
      else if(i==2){return CAT;}  
      else if(i==3){return PIG;}
  }
  
   public int code(){return this.code}  
  </code></pre>
  
  <p>Ok, so now the problem is that I create new object for ex. <code>Animal pet = dog();</code>
  But when I try to ask for the code I get <code>0</code>.  </p>
  
  <pre><code>system.out.print(pet.code()); 
  </code></pre>
  
  <p>The result is 0.<br>
  Is my implementation of the factory methods wrong or is is something else I am not seeing ?</p>