new mutator method that lets the user enter a number...
...but the method should check wether number is the first or the second in the calculation. This is done based on the previous action by the user - if it was a choice of calculation, the number entered is of course the second number. With no previous action by the user, the number is therefor the first number in the calculation.
In the field, we were to create a logical field keeping track of if the next number entered is the first or the second number in the calculation. Im pretty sure that I need to involve this in the new mutator method.
At the same time we were to make a a toString method changing a real number to string a string object shown with two decimals. Also very certain I need to include this in the new method.
The last field is the logical
Code:
public Calculator(int _firstNumber, int _secondNumber, char operatorChar, boolean _ctrlTest)
{
// initialise instance variables
_firstNumber = firstNumber;
_secondNumber = secondNumber;
operatorChar = " ";
_ctrlTest = ctrlTest;
}
...
some code left out
...
This is the toString method
Code:
public String toString()
{
DecimalFormat df = new DecimalFormat("#.##");
return df.format(firstNumber);
}
Im really without clues, so could you hint me away?