开发者_C百科
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this questionI've got a Calculator interface that contains
public interface Calculator {
public void setOperator(char operator);
public void setOperand (double operand);
public double getResult();
}
How would i implement this in another class, for a basic calculator???
Create a class that implements the Calculator interface and implement all the methods as desired.
public class CalculatorImpl implements Calculator {
public void setOperator(char operator) {
throw new UnsupportedOperationException("implement me.");
}
public void setOperand (double operand) {
throw new UnsupportedOperationException("implement me.");
}
public double getResult() {
throw new UnsupportedOperationException("implement me.");
}
}
精彩评论