* * Initialized by constructor, doesn't change. */ private ButtonObj zeroButton; /** * How to make one: Make a ButtonObj (i.e., my superclass) and * also remember that zero button. * * @param zeroButton The zero ButtonObj for this calculator. * @param gui The CalcTextGUI to keep track of. * @param stateObj The CalculatorState to keep track of. */ public DotButtonObj( ButtonObj zeroButton, CalcTextGUI gui, CalculatorState stateObj ) { super( gui, stateObj ); this.zeroButton = zeroButton; } /** * This method is called by the ButtonHandler whenever the * decimal point button is pressed.
* * How to handle (my button) being pressed? If we're already * reading a number, add the decimal point to the text and have * the state remember. If we're not reading a number (e.g., we * just saw an operation), pretend that the 0 was pressed first. */ public void handleButton() { if ( this.stateObj.notReadingNumber() ) // check whether we need { // to pretend that the 0 this.zeroButton.handleButton(); // button was pressed. } // now do dot press -- but only if we haven't already seen a // decimal point in this number. if ( this.stateObj.noDotYet() ) { this.stateObj.justSawDot(); this.gui.appendText( "." ); } } } /* * $Log: DotButtonObj.java,v $ * Revision 1.1.1.1 2002/06/05 21:56:25 root * CS101 comes to Olin finally. * * Revision 1.3 1997/10/30 03:28:35 lfgs * Added overview and fixed "* /" commenting typo in code. * * Revision 1.2 1997/10/24 22:20:41 las * Documented all of the code files, but didn't write the user manual (yet). * */