Java编写计算器的程序(求注释)

能不能帮我在关键位置注释一下呢?没怎么看懂这个程序
package JavaApplication2;
import java.awt.*;
import java.awt.event.*;
class CalculatorPanel extends Panel implements ActionListener
{
public CalculatorPanel(){
setLayout(new BorderLayout());
display = new TextField("0");
display.setEditable(false);
add(display, "North");
Panel p = new Panel();
p.setLayout(new GridLayout(4, 4));
String buttons = "789/456*123-0.=+";
for (int i = 0; i < buttons.length(); i++)
addButton(p, buttons.substring(i, i + 1));
add(p, "Center");
}
private void addButton(Container c, String s){
Button b = new Button(s);
c.add(b);
b.addActionListener(this);
}
public void actionPerformed(ActionEvent evt) {
String s = evt.getActionCommand();
if ('0' <= s.charAt(0) && s.charAt(0) <= '9'
|| s.equals(".")){
if (start) display.setText(s);
else display.setText(display.getText() + s);
start = false;
}
else{
if (start){
if (s.equals("-")) {
display.setText(s); start = false;
}
else op = s;
}
else{
double x = Double.parseDouble(display.getText());
calculate(x);
op = s;
start = true;
}
}
}
public void calculate(double n) {
if (op.equals("+")) arg += n;
else if (op.equals("-")) arg -= n;
else if (op.equals("*")) arg *= n;
else if (op.equals("/")) arg /= n;
else if (op.equals("=")) arg = n;
display.setText("" + arg);
}
private TextField display;
private double arg = 0;
private String op = "=";
private boolean start = true;
}
class CalculatorFrame extends Frame {
public CalculatorFrame() {
setTitle("Calculator");
setSize(200, 200);
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
} );
//Container contentPane = getContentPane();
this.add(new CalculatorPanel());
}
}
public class MyAWTCalculator {
public static void main(String args[] ) {
Frame frame = new CalculatorFrame();
frame.setVisible(true);
}
}
如果可以的话,能否帮忙逐行注释上面的程序

代码很多,大约90行代码.基本注释了每一行代码,

花了我比较长的时间.所以收费5财富吧




温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答
大家正在搜