重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
接口文档,代码层次(比如公共方法写在哪个class里),哪些为一大类在一个包下,数据字典,就是介绍你这个项目的架构让后来的人怎么能容易参与开发,交接什么看这个就可以方便些,辅助作用的一个文档一般都是项目经理写
我们提供的服务有:成都网站设计、成都网站建设、微信公众号开发、网站优化、网站认证、祥云ssl等。为上1000家企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的祥云网站制作公司
由于在java开发时我们得到的或者给别人的文件一般都是class文件,不会给出源文件,故编写一个简洁易懂的说明书是必须的。
ps: @param int[] arr 会有警告,可以删掉 int []。
用工具解析文档注释:javadoc工具
javadoc -d 目录 -d -author -version ArrayTool.java
有时会提示出错:找不到可以文档化的公共或受保护的类--在class前加一个public即可。
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.math.*;
public class HomeWork61 extends JFrame
{
JTextField memory=new JTextField();
JTextField number=new JTextField();
String before=new String();//存储没输入完的数
String first=new String();//第一个数
String second=new String();//第二个数
String symbol=new String();//存储运算符号
String remember=new String();
int point;//点过小数点否
class buttonlistener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
String s=e.getActionCommand();
if(s=="1"||s=="2"||s=="3"||s=="4"||s=="5"||s=="6"||s=="7"||s=="8"||s=="9"||s=="0"||s==".")
{
if(s!=".")
before=before+s;
else
if(point==0)
{
before=before+s;
point=1;
}
number.setText(before);
}
else
if(s=="+"||s=="-"||s=="*"||s=="/")
{
if(first=="")
first=before;
else
{
second=before;
String result=new String();
double finalnumber=0;
if(symbol=="+")
finalnumber=Double.parseDouble(first)+Double.parseDouble(second);
if(symbol=="-")
finalnumber=Double.parseDouble(first)-Double.parseDouble(second);
if(symbol=="*")
finalnumber=Double.parseDouble(first)*Double.parseDouble(second);
if(symbol=="/")
finalnumber=Double.parseDouble(first)/Double.parseDouble(second);
if(symbol=="=")
finalnumber=Double.parseDouble(first);
result=result.valueOf(finalnumber);
number.setText(result);
first=result;
point=0;
}
symbol=s;
before="";
point=0;
}
else
if(s=="=")
{
second=before;
before="";
String result=new String();
double finalnumber=0;
if(symbol=="+")
finalnumber=Double.parseDouble(first)+Double.parseDouble(second);
if(symbol=="-")
finalnumber=Double.parseDouble(first)-Double.parseDouble(second);
if(symbol=="*")
finalnumber=Double.parseDouble(first)*Double.parseDouble(second);
if(symbol=="/")
finalnumber=Double.parseDouble(first)/Double.parseDouble(second);
result=result.valueOf(finalnumber);
number.setText(result);
symbol="=";
first=result;
point=0;
}
if(s=="sin"||s=="cos"||s=="tan")//三角函数
{
if(first=="")
first=before;
before="";
String result=new String();
double finalnumber=0;
if(s=="sin")
finalnumber=Math.sin(Double.parseDouble(first));
if(s=="cos")
finalnumber=Math.cos(Double.parseDouble(first));
if(s=="tan")
finalnumber=Math.tan(Double.parseDouble(first));
result=result.valueOf(finalnumber);
number.setText(result);
first=result;
symbol="=";
point=0;
}
if(s=="+/-")//正负转换
{
if(first=="")
{
first=before;
before="";
String result=new String();
double finalnumber=Double.parseDouble(first);
finalnumber=-finalnumber;
result=result.valueOf(finalnumber);
number.setText(result);
first=result;
symbol="=";
point=0;
}
else
{
String result=new String();
double finalnumber=Double.parseDouble(before);
finalnumber=-finalnumber;
result=result.valueOf(finalnumber);
number.setText(result);
before=result;
point=0;
}
}
if(s=="M+")
{
if(before!="")
{
if(remember=="")
remember=before;
else
{
double finalnumber=Double.parseDouble(remember)+Double.parseDouble(before);
remember=remember.valueOf(finalnumber);
}
before="";
point=0;
memory.setText("M");
}
}
if(s=="MR")
{
if(remember!="")
number.setText(remember);
else
number.setText("0.");
}
if(s=="MC")
{
memory.setText("");
remember="";
}
if(s=="MS")
{
if(before!="")
{
remember=before;
before="";
point=0;
memory.setText("M");
}
}
if(s=="C")//清除屏幕
{
before="";
first="";
second="";
symbol="";
point=0;
number.setText("0.");
}
}
}
public static void main(String[] args)
{
HomeWork61 myhomework=new HomeWork61("calculator");//生成对象
myhomework.setSize(400,200);//设置大小
myhomework.setVisible(true);//设置成可见
}
public HomeWork61(String title)
{
super(title);//设置标题
Container cp = getContentPane();
JPanel button=new JPanel();
JPanel result=new JPanel();
remember="";
before="";
first="";
second="";
symbol="";
point=0;
JButton c=new JButton();
button.setLayout(new GridLayout(4,6));
result.setLayout(new GridLayout(1,3));
JButton[] btn=new JButton[24];
btn[0]=new JButton("sin");
btn[1]=new JButton("MC");
btn[2]=new JButton("0");
btn[3]=new JButton("1");
btn[4]=new JButton("2");
btn[5]=new JButton("+");
btn[6]=new JButton("cos");
btn[7]=new JButton("MR");
btn[8]=new JButton("3");
btn[9]=new JButton("4");
btn[10]=new JButton("5");
btn[11]=new JButton("-");
btn[12]=new JButton("tan");
btn[13]=new JButton("MS");
btn[14]=new JButton("6");
btn[15]=new JButton("7");
btn[16]=new JButton("8");
btn[17]=new JButton("*");
btn[18]=new JButton("+/-");
btn[19]=new JButton("M+");
btn[20]=new JButton("9");
btn[21]=new JButton(".");
btn[22]=new JButton("=");
btn[23]=new JButton("/");
c=new JButton("C");
for(int i=0;i24;i++)
{
btn[i].addActionListener(new buttonlistener());
button.add(btn[i]);
}
c.addActionListener(new buttonlistener());
result.add(BorderLayout.EAST,memory);
result.add(BorderLayout.CENTER,c);
result.add(BorderLayout.WEST,number);
cp.add(BorderLayout.NORTH,result);
cp.add(BorderLayout.SOUTH,button);
number.setText("0.");
}
}
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.math.*;
public class HomeWork61 extends JFrame
{
JTextField memory=new JTextField();
JTextField number=new JTextField();
String before=new String();//存储没输入完的数
String first=new String();//第一个数
String second=new String();//第二个数
String symbol=new String();//存储运算符号
String remember=new String();
int point;//点过小数点否
class buttonlistener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
String s=e.getActionCommand();
if(s=="1"||s=="2"||s=="3"||s=="4"||s=="5"||s=="6"||s=="7"||s=="8"||s=="9"||s=="0"||s==".")
{
if(s!=".")
before=before+s;
else
if(point==0)
{
before=before+s;
point=1;
}
number.setText(before);
}
else
if(s=="+"||s=="-"||s=="*"||s=="/")
{
if(first=="")
first=before;
else
{
second=before;
String result=new String();
double finalnumber=0;
if(symbol=="+")
finalnumber=Double.parseDouble(first)+Double.parseDouble(second);
if(symbol=="-")
finalnumber=Double.parseDouble(first)-Double.parseDouble(second);
if(symbol=="*")
finalnumber=Double.parseDouble(first)*Double.parseDouble(second);
if(symbol=="/")
finalnumber=Double.parseDouble(first)/Double.parseDouble(second);
if(symbol=="=")
finalnumber=Double.parseDouble(first);
result=result.valueOf(finalnumber);
number.setText(result);
first=result;
point=0;
}
symbol=s;
before="";
point=0;
}
else
if(s=="=")
{
second=before;
before="";
String result=new String();
double finalnumber=0;
if(symbol=="+")
finalnumber=Double.parseDouble(first)+Double.parseDouble(second);
if(symbol=="-")
finalnumber=Double.parseDouble(first)-Double.parseDouble(second);
if(symbol=="*")
finalnumber=Double.parseDouble(first)*Double.parseDouble(second);
if(symbol=="/")
finalnumber=Double.parseDouble(first)/Double.parseDouble(second);
result=result.valueOf(finalnumber);
number.setText(result);
symbol="=";
first=result;
point=0;
}
if(s=="sin"||s=="cos"||s=="tan")//三角函数
{
if(first=="")
first=before;
before="";
String result=new String();
double finalnumber=0;
if(s=="sin")
finalnumber=Math.sin(Double.parseDouble(first));
if(s=="cos")
finalnumber=Math.cos(Double.parseDouble(first));
if(s=="tan")
finalnumber=Math.tan(Double.parseDouble(first));
result=result.valueOf(finalnumber);
number.setText(result);
first=result;
symbol="=";
point=0;
}
if(s=="+/-")//正负转换
{
if(first=="")
{
first=before;
before="";
String result=new String();
double finalnumber=Double.parseDouble(first);
finalnumber=-finalnumber;
result=result.valueOf(finalnumber);
number.setText(result);
first=result;
symbol="=";
point=0;
}
else
{
String result=new String();
double finalnumber=Double.parseDouble(before);
finalnumber=-finalnumber;
result=result.valueOf(finalnumber);
number.setText(result);
before=result;
point=0;
}
}
if(s=="M+")
{
if(before!="")
{
if(remember=="")
remember=before;
else
{
double finalnumber=Double.parseDouble(remember)+Double.parseDouble(before);
remember=remember.valueOf(finalnumber);
}
before="";
point=0;
memory.setText("M");
}
}
if(s=="MR")
{
if(remember!="")
number.setText(remember);
else
number.setText("0.");
}
if(s=="MC")
{
memory.setText("");
remember="";
}
if(s=="MS")
{
if(before!="")
{
remember=before;
before="";
point=0;
memory.setText("M");
}
}
if(s=="C")//清除屏幕
{
before="";
first="";
second="";
symbol="";
point=0;
number.setText("0.");
}
}
}
public static void main(String[] args)
{
HomeWork61 myhomework=new HomeWork61("calculator");//生成对象
myhomework.setSize(400,200);//设置大小
myhomework.setVisible(true);//设置成可见
}
public HomeWork61(String title)
{
super(title);//设置标题
Container cp = getContentPane();
JPanel button=new JPanel();
JPanel result=new JPanel();
remember="";
before="";
first="";
second="";
symbol="";
point=0;
JButton c=new JButton();
button.setLayout(new GridLayout(4,6));
result.setLayout(new GridLayout(1,3));
JButton[] btn=new JButton[24];
btn[0]=new JButton("sin");
btn[1]=new JButton("MC");
btn[2]=new JButton("0");
btn[3]=new JButton("1");
btn[4]=new JButton("2");
btn[5]=new JButton("+");
btn[6]=new JButton("cos");
btn[7]=new JButton("MR");
btn[8]=new JButton("3");
btn[9]=new JButton("4");
btn[10]=new JButton("5");
btn[11]=new JButton("-");
btn[12]=new JButton("tan");
btn[13]=new JButton("MS");
btn[14]=new JButton("6");
btn[15]=new JButton("7");
btn[16]=new JButton("8");
btn[17]=new JButton("*");
btn[18]=new JButton("+/-");
btn[19]=new JButton("M+");
btn[20]=new JButton("9");
btn[21]=new JButton(".");
btn[22]=new JButton("=");
btn[23]=new JButton("/");
c=new JButton("C");
for(int i=0;i24;i++)