JAVA的注释,呜呜,大家帮我注释几句就OK了~急

[复制链接]
查看11 | 回复4 | 2010-7-6 12:17:17 | 显示全部楼层 |阅读模式
import java.awt.*;
import java.awt.event.*;
public class jisuanqi extends WindowAdapter
{
Panel p1=new Panel();
Panel p2=new Panel();
Panel p3=new Panel();
TextField txt;
private Button[] b=new Button[17];
private String ss[]= {"7","8","9","+","4","5","6","-","1","2","3","*","0","/","=","清空","关闭"};
static double a;
static String s,str;
public static void main(String args[])
{

(new jisuanqi()).frame();
}
public void frame()
{
Frame fm=new Frame("简易计算器");
for (int i=0;i<=16;i++)
{
b=new Button(ss);
}
for(int i=0;i<=15;i++)
{
p2.add(b);
}
b[16].setBackground(Color.blue);
txt=new TextField(15);
txt.setEditable(false);
for(int i=0;i<=16;i++)
{
b.addActionListener(new buttonlistener());
}
b[16].addActionListener(new close());
fm.addWindowListener(this);
fm.setBackground(Color.red);
p1.setLayout(new BorderLayout());
p1.add(txt,"North");
p2.setLayout(new GridLayout(4,4));
p3.setLayout(new BorderLayout());
p3.add(b[16]);
fm.add(p1,"North");
fm.add(p2,"Center");
fm.add(p3,"South");
fm.pack();
fm.show();
}
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
class buttonlistener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
Button btn=(Button)e.getSource();
if( btn.getLabel()=="=")
{
jisuan();
str=String.valueOf(a);
txt.setText(str);
s="";
}
else if(btn.getLabel()=="+")
{
jisuan();

txt.setText("");
s="+";
}
else if(btn.getLabel()=="-")
{
jisuan();

txt.setText("");

s="-";
}
else if(btn.getLabel()=="/")
{

jisuan();

txt.setText("");

s="/";


}
else if(btn.getLabel()=="*")
{

jisuan();

txt.setText("");

s="*";
}
else
{

txt.setText(txt.getText()+btn.getLabel());



if (btn.getLabel()=="清空")

txt.setText("");
}
}
public void jisuan()
{
if (s=="+")
a+=Double.parseDouble(txt.getText());
else if (s=="-")
a-=Double.parseDouble(txt.getText());
else if(s=="*")
a*=Double.parseDouble(txt.getText());
else if(s=="/")
a/=Double.parseDouble(txt.getText());
else
a=Double.parseDouble(txt.getText());
}
}
}
class close implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
System.exit(0);
}
}
就是对其中的重点语句进行下简单的注释就可以~

回复

使用道具 举报

千问 | 2010-7-6 12:17:17 | 显示全部楼层
你是不会注释啊,还是有不会的问题啊,什么叫帮你注释几句
回复

使用道具 举报

千问 | 2010-7-6 12:17:17 | 显示全部楼层
我懂了 楼主就是想偷懒 应付作业不会写注释 就不是程序员
回复

使用道具 举报

千问 | 2010-7-6 12:17:17 | 显示全部楼层
多看看API,这些都是很简单的
回复

使用道具 举报

千问 | 2010-7-6 12:17:17 | 显示全部楼层
哥没事要多看点教程了
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行