package nai4;

/**
 * @author Daniel "3ICE" Berezvai
 */
public class Mushroom{
  Type type;
  int weight;

  public Mushroom(Type type, int weight){
    this.type=type;
    this.weight=weight;
    //System.out.println(this.toString());
  }

  @Override
  public String toString(){
    return type+" "+weight;
  }

  public static Type parseType(String t){
    switch(t){
    case "C":
      return Type.C;
    case "R":
      return Type.R;
    case "L":
      return Type.L;
    default:
      throw new NullPointerException("Incorrect type!");
    }
  }

  public boolean lessThan(Mushroom other){
    //B. Először mindig a legnagyobb (legnehezebb) gombát szedi le...
    boolean ret=this.weight>other.weight;
    //C. Azonos súlyú gombák esetén...
    if(this.weight==other.weight){
      //először Csiperké(ke)t, majd a Rókagombá(ka)t, és legvégül a Lila pereszkéket szedi le.
      ret=this.type.getValue()>other.type.getValue();
    }
    //System.err.println("this = "+this);
    //System.err.println("other = "+other);
    //System.err.println("greaterThan = "+ret);
    return ret;
  }

  boolean greaterThan(Mushroom other){
    //B. Először mindig a legnagyobb (legnehezebb) gombát szedi le...
    boolean ret=this.weight<other.weight;
    //C. Azonos súlyú gombák esetén...
    if(this.weight==other.weight){
      //először Csiperké(ke)t, majd a Rókagombá(ka)t, és legvégül a Lila pereszkéket szedi le.
      ret=this.type.getValue()<other.type.getValue();
    }
    //System.err.println("this = "+this);
    //System.err.println("other = "+other);
    //System.err.println("lessThan = "+ret);
    return ret;
  }
}
