Hi I'm just starting out with OOPin JAVA and thought i was getting the hang of it but i've been given an assignment and it's got me stumped.
here is the code i have been given
public class FrogCalculator
{
private Frog operand1Frog;
private Frog operand2Frog;
private Frog unitsFrog;
private Frog tensFrog;
private OUColour colour;
/**
* Constructor for objects of class FrogCalculator
*/
public FrogCalculator()
{
Super();
}
/* instance methods */
/**
* Returns the receiver's operand1Frog
*/
public Frog getOperand1Frog()
{
return operand1Frog;
}
/**
* Sets the receiver's operand1Frog
*/
public void setOperand1Frog(Frog operand1Frog)
{
this.operand1Frog = operand1Frog;
}
/**
* Returns the receiver's operand2Frog
*/
public Frog getOperand2Frog()
{
return operand2Frog;
}
/**
* Sets the receiver's operand2Frog
*/
public void setOperand2Frog(Frog operand2Frog)
{
this.operand2Frog = operand2Frog;
}
/**
* Returns the receiver's unitsFrog
*/
public Frog getUnitsFrog()
{
return unitsFrog;
}
/**
* Sets the receiver's unitsFrog
*/
public void setUnitsFrog(Frog unitsFrog)
{
this.unitsFrog = unitsFrog;
}
/**
* Returns the receiver's tensFrog
*/
public Frog getTensFrog()
{
return tensFrog;
}
/**
* Sets the receiver's tensFrog
*/
public void setTensFrog(Frog tensFrog)
{
this.tensFrog = tensFrog;
}
}
here is what i am being asked to do;
Write code in the FrogCalculator class to modify the signature of the default constructor for FrogCalculator such that it takes four arguments of type Frog. The positions of the two Frog instances referenced by the first and second arguments represent the first and second operands, respectively. The positions of the two Frog
instances referenced by the third and fourth arguments represent the result of the calculation: the third Frog instance being the ‘tens’ frog and the fourth Frog instance being the ‘units’ frog.
The constructor should assign the arguments directly to the four corresponding private instance variables and then set the frog referenced by tensFrog to brown and the frog referenced by unitsFrog to yellow.
But i just don't know how?? I know that FrogCalculator class willinherit the positon and colour of the superclass frog, but i'm at a loss for what code i have to add.
can anyone help me??