// Star.java 

/** A regular expression representing the Kleene * of a 
 *  regular expression.
 *  @author <a href="mailto:bergmann@rowan.edu"> Seth Bergmann </a>
 *  @author <a href="mailto:gspyo@jersey.net"> Greg Safko </a>
 */
public class Star extends Expr
{  

   /** Constructor for a star.
    *  @param s The regular expression to be "starred"
    */
   public Star (Expr s)
   {	
   		super (s.reduce()); 
   }


  public boolean equals(Expr s)
  {
  	if(s instanceof Star)
		if(this.getValue() == s.getValue())
			return true;
		  	
  	return false; 	
  }
  
  
  public Expr reduce()
  {
  	if(this.getStar() instanceof Star)
  		return this.getStar();
  
  	return this; // in case the expression cannot be reduced further 	
  }

   /** Return the star in the form of a string which
    *  people can understand.
    */
    
   public String toString ()
   {  	
    // return the ToString, and also append the "*" symbol
		return  this.getStar().reduce().toString() + "*";
   }

}

