ImageVerifierCode 换一换
你正在下载:

javalz.docx

[预览]
格式:DOCX , 页数:16 ,大小:143.35KB ,
资源ID:3457184      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/3457184.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(javalz.docx)为本站会员(b****6)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

javalz.docx

1、javalzJava 程 序 设 计 实 验 报 告专 业: 信息与计算科学 班 级: 0701班 学 号: 0708060102 姓 名: 吝 芝 2009 年 12 月 11 日一、功能描述编程实现一个学生成绩管理系统的图形界面,在系统中可以添加学生成绩信息,修改学生成绩信息,或者删除学生成绩信息,也可以查询学生成绩信息。二、类描述类 名属 性方 法备 注StudentsStudentInf SIpublic void init()String xmString bjint iint jpublic void actionPerformed(ActionEvent e)int xhint

2、cjstatic int midLabel prompt1public void search(int k)Label prompt2Label prompt3Label prompt4Label prompt5public void Insert(StudentInf q)TextField input1TextField input2TextField input3void ChengJi()TextField input4Button btn1Button btn2void XingMing()Button btn3Button btn4OverExceptionString overE

3、mptyExcepyionString emptyStudentInfprivate String nameStudentInf(String xingming,int xuehao,String banji,int chengji)private int StuNopublic String getname()public int getStuNo()private String ClassNopublic String getClassNo()public int getLevel()private int Level附:源程序代码框架import java.applet.Applet;i

4、mport java.awt.*;import java.awt.event.*;import java.util.*;import java.lang.*;public class Students extends Applet implements ActionListener public void init() public void actionPerformed(ActionEvent e) public void search(int k) public void Insert(StudentInf q) class OverException extends Exception

5、 String over; class EmptyException extends Exception String empty; void XingMing() void ChengJi() public class StudentInf StudentInf(String xingming,int xuehao,String banji,int chengji) public int getStuNo() return StuNo; public String getname() return name; public String getClassNo() return ClassNo

6、; public int getLevel() return Level; 三、界面设计与事件处理public class Students extends Applet implements ActionListener Label prompt1=new Label(学生管理系统); Label prompt2=new Label(用户:); Label prompt3=new Label(密码:); Label prompt4=new Label(班级:); Label prompt5=new Label(成绩:); TextField input1=new TextField(8);

7、TextField input2=new TextField(8); TextField input3=new TextField(8); TextField input4=new TextField(8); Button btn1=new Button(登录); Button btn2=new Button(增加); Button btn3=new Button(修改); Button btn4=new Button(删除); public void init() setLayout(new GridLayout(8,3); add(new Label(); add(prompt1); ad

8、d(new Label(); add(prompt2); add(input1); add(new Label(); add(prompt3); add(input2); add(btn1); add(prompt4); add(input3); add(new Label(); add(prompt5); add(input4); add(new Label(); add(btn2); add(btn3); add(btn4); prompt4.setVisible(false); prompt5.setVisible(false); input3.setVisible(false); in

9、put4.setVisible(false); btn2.setVisible(false); btn3.setVisible(false); btn4.setVisible(false); btn1.addActionListener(this); btn2.addActionListener(this); btn3.addActionListener(this); btn4.addActionListener(this); public void actionPerformed(ActionEvent e) if(e.getActionCommand()=登录) String a,b; a

10、=input1.getText(); b=input2.getText(); input1.setText(); if(a.equals(lz)=true)&(b.equals(02)=true) prompt2.setText( 姓名:); prompt3.setText( 学号:); prompt4.setVisible(true); prompt5.setVisible(true); input3.setVisible(true); input4.setVisible(true); btn2.setVisible(true); btn3.setVisible(true); btn4.se

11、tVisible(true); btn3.setEnabled(false); btn4.setEnabled(false); btn1.setLabel(查询); input1.setText(登录成功); input1.selectAll(); else input2.setText(用户名或密码错); if(e.getActionCommand()=增加) boolean scucss=true; try XingMing(); catch(EmptyException as) input1.setText(姓名不能为空); scucss=false; try xh=Integer.pa

12、rseInt(input2.getText(); catch(NumberFormatException m) input2.setText(学号为空或格式错); scucss=false; bj=input3.getText(); try ChengJi(); catch(EmptyException as) cj=-1; catch(OverException dd) input4.setText(应在0-100间); scucss=false; catch(NumberFormatException cm) input4.setText(成绩应为数据); scucss=false; if

13、(scucss=true) SI=new StudentInf(xm,xh,bj,cj); Insert(SI); if(e.getActionCommand()=修改) xm=input1.getText(); xh=Integer.parseInt(input2.getText(); bj=input3.getText(); cj=Integer.parseInt(input4.getText(); SI=new StudentInf(xm,xh,bj,cj); StuInf.setElementAt(SI, mid); btn3.setEnabled(false); if(e.getAc

14、tionCommand()=删除) StuInf.removeElementAt(mid); btn4.setEnabled(false); input1.setText(删除成功); input2.setText(); input3.setText(); input4.setText(); if(e.getActionCommand()=查询) boolean right=true; try xh=Integer.parseInt(input2.getText(); catch(NumberFormatException m) input2.setText(学号为空或格式错); right=

15、false; if(right=true) search(xh); btn3.setEnabled(true); btn4.setEnabled(true); /查找方法 public void search(int k) boolean exist=false; int low=0; int high=StuInf.size()-1; while(low=high) mid=(high+low)/2; StudentInf a1=(StudentInf) StuInf.elementAt(mid); if(a1.getStuNo()=k) SI=(StudentInf) StuInf.ele

16、mentAt(mid); String x = String.valueOf(SI.getStuNo(); exist=true; input1.setText(SI.getname(); input1.selectAll(); input2.setText(0+x); input3.setText(SI.getClassNo(); if(SI.getLevel()=-1) input4.setText(未参加考试); else String y = String.valueOf(SI.getLevel(); input4.setText(y); break; else if(a1.getSt

17、uNo()k) low=mid+1; else high=mid-1; if(exist=false) input1.setText(无此学号学生信息); input1.selectAll(); /添加方法 public void Insert(StudentInf q) int i=0; if(StuInf.isEmpty()=true) StuInf.addElement(q); input1.setText(); input2.setText(); input3.setText(); input4.setText(); else StudentInf xh; xh=(StudentInf

18、) StuInf.firstElement(); while(xh.getStuNo()q.getStuNo() i+; if(iStuInf.size() xh=(StudentInf) StuInf.elementAt(i); else break; if(xh.getStuNo()=q.getStuNo() input2.setText(此学生信息已存在); input2.requestFocus(); input2.selectAll(); else StuInf.insertElementAt(q,i); input1.setText(); input2.setText(); inp

19、ut3.setText(); input4.setText(); /异常类 class OverException extends Exception String over; class EmptyException extends Exception String empty; void XingMing()throws EmptyException if(input1.getText().equals() throw (new EmptyException(); else xm=input1.getText(); void ChengJi() throws OverException,E

20、mptyException if(input4.getText().equals() throw(new EmptyException(); else cj=Integer.parseInt(input4.getText(); if(cj100) throw (new OverException(); /学生信息类 public class StudentInf private String name; private int StuNo; private String ClassNo; private int Level; StudentInf(String xingming,int xue

21、hao,String banji,int chengji) name=xingming; StuNo=xuehao; ClassNo=banji; Level=chengji; public int getStuNo() return StuNo; public String getname() return name; public String getClassNo() return ClassNo; public int getLevel() return Level; 四、运行结果五实验心得Java程序设计语言是十分重要的学科,学习Java语言,重要的是要多看、多想、多练习。通过本次实验,对图形用户界面的设计及事件处理有了更深一步的理解, 虽然刚开始时遇到了一些问题,但通过查资料,阅读课本,终于把报告做完了,但对于调式程序还是有一定的难度。这次试验让我知道,平时要多了解算法,多做程序,可以提高自己的设计和编程能力。

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1