/**
 * Class Operand - write a description of the class here
 * 
 * @author: Kleanthis Thramboulidis
 * date: 
 */

public class Operand
{
	public StringBuffer buf;
	
	 /**
     * Constructor for objects of class Operand
     */

	public Operand()
     { buf = new StringBuffer(14); }

	public Operand(double val)
     { 
	  this();
	  buf.append(Double.toString(val));
	 }

	public void addDigit(char ch)
     {
      buf.append(ch);
      Calculator.gui.display.setText(buf.toString());
     }   
    // Otan stalei mhnyma apo thn CalculatorGui gia addDigit ston op tote o op :
    //     i) prosthetei to pshfio sthn StringBuffer kai meta
    //    ii) epistrefei (sthn Display tou Caclulator kai tou Operand Status) ta periexomena ths
    //        StringBuffer san seira xarakthrwn (dhladh deixnei sthn othonh ta pshfia pou exoume pathsei)
   
	public void deleteLastDigit()
     {
	  String s =new String(buf);
	  buf = new StringBuffer(s.substring(0,s.length()-1));
      Calculator.gui.display.setText(buf.toString());
	 }

	public void reset()
     {
      buf = new StringBuffer(14);
      Calculator.gui.display.setText("0");
     }

	public void set(double val) 
     { 
	  reset();
	  buf.append(val);
      Calculator.gui.display.setText(buf.toString());
	 }

	public void complete()
     {      
      Double d = new Double(buf.toString());
	  Calculator.s.push(d);
	  reset();
     }
}
  
   

