作业要求来自:https://edu.cnblogs.com/campus/gzcc/GZCC-16SE2/homework/2232
GitHub远程仓库的地址:https://github.com/zzj79/1234zzj
基本要求:
8个可扩展方向:
public class computer extends JFrame
{
computer()
{
super("简易计算器");
Font f=new Font("黑体",30,30);
JTextField jt1=new JTextField(null);
JTextField jt2=new JTextField(null);
jt1.setFont(f);
jt2.setFont(f);
jt1.setHorizontalAlignment(JTextField.RIGHT);
jt2.setHorizontalAlignment(JTextField.RIGHT);
Container c=getContentPane();
c.setLayout(new FlowLayout(FlowLayout.LEFT,5,5));
c.add(jt1);
c.add(jt2);
jt1.setPreferredSize(new Dimension(370,70));
jt2.setPreferredSize(new Dimension(370,75));
jt1.setEditable(false);jt2.setEditable(false);
JButton jb[]=new JButton[16];
for(int j=0;j<16;j++)
{
jb[j]=new JButton();
jb[j].setBackground(Color.WHITE);
jb[j].setFocusable(false);
jb[j].setPreferredSize(new Dimension(90,90));
jb[j].setFont(f);
c.add(jb[j]);
}
this.setResizable(false);
//再定义一个计算类calculation.java:
public class calculation {
calculation(){};
boolean is_operator(char ch)
{
if(ch==‘+‘||ch==‘-‘||ch==‘*‘||ch==‘/‘)return true;
else return false;
}
static int result(String s)
{
String ch[]={"+","-","*","/"};
int i=0;int index;
while(s.indexOf(ch[i])==-1&&i<4){i++;}
if(i==4)return -1;
else index=s.indexOf(ch[i]);
String s1=s.substring(0, index);
String s2=s.substring(index+1, s.length());
if(i==0)return Integer.parseInt(s1)+Integer.parseInt(s2);
if(i==1)return Integer.parseInt(s1)-Integer.parseInt(s2);
if(i==2)return Integer.parseInt(s1)*Integer.parseInt(s2);
if(i==3&&Integer.parseInt(s2)!=0)return Integer.parseInt(s1)/Integer.parseInt(s2);
else if(i==3&&Integer.parseInt(s2)==0){throw new ArithmeticException();}
return -1;
}
}
| PSP2.1 | Personal Software Process Stages | Time Senior Student | Time |
| Planning | 计划 | 8 | 6 |
| · Estimate | 估计这个任务需要多少时间 | 12 | 10 |
| Development | 开发 | 60 | 40 |
| · Analysis | 需求分析 (包括学习新技术) | 8 | 10 |
| · Design Spec | 生成设计文档 | 0 | 0 |
| · Design Review | 设计复审 | 3 | 5 |
| · Coding Standard | 代码规范 | 4 | 3 |
| · Design | 具体设计 | 10 | 13 |
| · Coding | 具体编码 | 35 | 25 |
| · Code Review | 代码复审 | 10 | 9 |
| · Test | 测试(自我测试,修改代码,提交修改) | 10 | 20 |
| Reporting | 报告 | 9 | 6 |
| · | 测试报告 | 0 | 0 |
| · | 计算工作量 | 5 | 2 |
| · | 并提出过程改进计划 | 0 | 0 |
效率还可以,一开始我们各自提出了自己的想法,然后商量取舍问题,就开始进行编程。在整个过程中,都积极参与。

原文:https://www.cnblogs.com/1234zzj/p/9870008.html