软件开发基础实践报告形式

上传人:M****1 文档编号:501511657 上传时间:2023-08-06 格式:DOC 页数:24 大小:96.50KB
返回 下载 相关 举报
软件开发基础实践报告形式_第1页
第1页 / 共24页
软件开发基础实践报告形式_第2页
第2页 / 共24页
软件开发基础实践报告形式_第3页
第3页 / 共24页
软件开发基础实践报告形式_第4页
第4页 / 共24页
软件开发基础实践报告形式_第5页
第5页 / 共24页
点击查看更多>>
资源描述

《软件开发基础实践报告形式》由会员分享,可在线阅读,更多相关《软件开发基础实践报告形式(24页珍藏版)》请在金锄头文库上搜索。

1、中国矿业大学徐海学院软件开发基础实践报告姓 名: 赵辉 学 号: 专 业: 计算机科学与技术 指导教师: 孙锦程 职 称: 教师 2012 年 6 月 30 徐州姓名/学号: 赵辉/22110478 班级: 计算机科学与技术 一、程序来源: 去图书馆查阅资料以及java书上代码二、程序项目名称:java计算器三、 程序原理: 声明三个面板的布局 ,实例化三个面板的布局 ,实例化所有按钮、设置其前景色并注册监听器 ,创建一个空字符串缓冲区 ,添加面板p0,p1,p2,p3中的组件和设置其在框架中的位置和大小 ,设置框架中的布局为空布局并添加4个面板,匿名类关闭窗口 ,再构造监听器 ,选择CE清零

2、,把显示屏清零 ,清空字符串缓冲区以准备接收新的输入运算数 ,重复显示屏清零,清空缓冲区以便接收新的另一个运算数 ,就这样一个小型计算器建成了。四、程序功能:简单的+,-,*,/运算五、程序内容(输入输出): 输入想要输入的数,进行加减乘除,然后得出结果。六、数据流分析(定义的变量,类型,数组,类型,结构体):Double x y,int z;运用构造函数,继承方法;运用if,else if,catch语句等。七、程序代码分析(每个函数和代码模块的功能作用分析):public class Counter extends Frame /继承方法public Counter()/无参构造函数 ad

3、dWindowListener(new WindowAdapter() public void windowClosing(WindowEvent e1) /写一个关闭窗口方法 class Bt implements ActionListener public void actionPerformed(ActionEvent e2)/构造监听器 public static void main(String args) new Counter();/定义一个类八、控制流分析(源程序整体流程图):九、 源代码优点,好处:操作简单方面快捷,还可以存储一些数据,实用。十、 总结及心得体会: 通过这次软

4、件开发实验报告我学到程序的代码真的得需要平时的大量积累收集才能一步步运用得得心应手,有些代码其实可以直接运用到这上面来,不需要再花大量的时间来敲代码。十一、对源程序过程及方法、手段的改进建议: 可以适当的运用for循环来提高代码的简单度,也就是缩小代码量。报告评分: 指导教师签字:import java.awt.Button;import java.awt.Color;import java.awt.Frame;import java.awt.GridLayout;import java.awt.Panel;import java.awt.TextField;import java.awt.e

5、vent.*; import java.lang.*; import javax.swing.*; public class Counter extends Frame /声明三个面板的布局 GridLayout gl1,gl2,gl3; Panel p0,p1,p2,p3; JTextField tf1; TextField tf2; Button b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15,b16,b17,b18,b19,b20,b21,b22,b23,b24,b25,b26; StringBuffer str;/显示屏所显示

6、的字符串 double x,y;/x和y都是运算数 int z;/Z表示单击了那一个运算符.0表示+,1表示-,2表示*,3表示/ static double m;/记忆的数字 public Counter() gl1=new GridLayout(1,4,10,0);/实例化三个面板的布局 gl2=new GridLayout(4,1,0,15); gl3=new GridLayout(4,5,10,15); tf1=new JTextField(27);/显示屏 tf1.setHorizontalAlignment(JTextField.RIGHT); tf1.setEnabled(fal

7、se); tf1.setText(0); tf2=new TextField(10);/显示记忆的索引值 tf2.setEditable(false); /实例化所有按钮、设置其前景色并注册监听器 b0=new Button(Backspace); b0.setForeground(Color.red); b0.addActionListener(new Bt(); b1=new Button(CE); b1.setForeground(Color.red); b1.addActionListener(new Bt(); b2=new Button(C); b2.setForeground(C

8、olor.red); b2.addActionListener(new Bt(); b3=new Button(MC); b3.setForeground(Color.red); b3.addActionListener(new Bt(); b4=new Button(MR); b4.setForeground(Color.red); b4.addActionListener(new Bt(); b5=new Button(MS); b5.setForeground(Color.red); b5.addActionListener(new Bt(); b6=new Button(M+); b6

9、.setForeground(Color.red); b6.addActionListener(new Bt(); b7=new Button(7); b7.setForeground(Color.blue); b7.addActionListener(new Bt(); b8=new Button(8); b8.setForeground(Color.blue); b8.addActionListener(new Bt(); b9=new Button(9); b9.setForeground(Color.blue); b9.addActionListener(new Bt(); b10=n

10、ew Button(/); b10.setForeground(Color.red); b10.addActionListener(new Bt(); b11=new Button(sqrt); b11.setForeground(Color.blue); b11.addActionListener(new Bt(); b12=new Button(4); b12.setForeground(Color.blue); b12.addActionListener(new Bt(); b13=new Button(5); b13.setForeground(Color.blue); b13.add

11、ActionListener(new Bt(); b14=new Button(6); b14.setForeground(Color.blue); b14.addActionListener(new Bt(); b15=new Button(*); b15.setForeground(Color.red); b15.addActionListener(new Bt(); b16=new Button(%); b16.setForeground(Color.blue); b16.addActionListener(new Bt(); b17=new Button(1); b17.setFore

12、ground(Color.blue); b17.addActionListener(new Bt(); b18=new Button(2); b18.setForeground(Color.blue); b18.addActionListener(new Bt(); b19=new Button(3); b19.setForeground(Color.blue); b19.addActionListener(new Bt(); b20=new Button(-); b20.setForeground(Color.red); b20.addActionListener(new Bt(); b21

13、=new Button(1/X); b21.setForeground(Color.blue); b21.addActionListener(new Bt(); b22=new Button(0); b22.setForeground(Color.blue); b22.addActionListener(new Bt(); b23=new Button(+/-); b23.setForeground(Color.blue); b23.addActionListener(new Bt(); b24=new Button(.); b24.setForeground(Color.blue); b24

14、.addActionListener(new Bt(); b25=new Button(+); b25.setForeground(Color.red); b25.addActionListener(new Bt(); b26=new Button(=); b26.setForeground(Color.red); b26.addActionListener(new Bt(); /实例化四个面板 p0=new Panel(); p1=new Panel(); p2=new Panel(); p3=new Panel(); /创建一个空字符串缓冲区 str=new StringBuffer(); /添加面板p0中的组件和设置其在框架中的位置和大小 p0.add(tf1); p0.setBounds(10,25,300,40); /添加面板p1中的组件和设置其在框架中的位置和大小

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 建筑/环境 > 施工组织

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号