资源描述:
《学生信息管理java》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、/***AWTSampleapplication**@author*@version1.0012/05/06*/importjavax.swing.*;importjava.io.*;importjava.awt.*;importjava.awt.event.*;importjava.util.*;publicclassUnit{publicstaticvoidmain(String[]args){VectorstuList=newVector();Stringstu="",line="",input="",name="";booleanfl
2、ag=true;intvalue,age;line="请选择你要的操作1.增加学生2.修改学生信息3.删除学生4.浏览所有学生信息5.统计学生人数6.退出系统";while(flag){JOptionPane.showMessageDialog(null,line,"结果",JOptionPane.PLAIN_MESSAGE);input=JOptionPane.showInputDialog("请输入数字,选择你要的操作");value=Integer.parseInt(input);if(value==1){name=JOpt
3、ionPane.showInputDialog("请输入要添加的学生的名字:");age=Integer.parseInt(JOptionPane.showInputDialog("请输入要添加学生的年龄:"));studentStudent=newstudent(name,age);stuList.add(Student);/*Enumerationitems=stuList.elements();Objecto=items.nextElement();Studentsample=(Student)o;JOptionPane.showMes
4、sageDialog(null,sample.getName(),"结果",JOptionPane.PLAIN_MESSAGE);*/}elseif(value==2){name=JOptionPane.showInputDialog("请输入你要修改的学生的名字");input=JOptionPane.showInputDialog("请输入你要修改后的学生的年龄");age=Integer.parseInt(input);Enumerationitems=stuList.elements();while(items.hasMoreElem
5、ents()){//Stringnamestr=S;studentStu=(student)items.nextElement();if(Stu.getName().equals(name)){Stu.Update(age);break;}}JOptionPane.showMessageDialog(null,"修改成功!","结果",JOptionPane.PLAIN_MESSAGE);}elseif(value==3){name=JOptionPane.showInputDialog("请输入你要删除的学生的名字");Enumeratio
6、nitems=stuList.elements();while(items.hasMoreElements()){//Stringnamestr=S;studentStu=(student)items.nextElement();if(Stu.getName().equals(name)){stuList.remove(Stu);break;}}JOptionPane.showMessageDialog(null,"删除成功!","结果",JOptionPane.PLAIN_MESSAGE);}elseif(value==4){printVe
7、ctor(stuList);}elseif(value==5){JOptionPane.showMessageDialog(null,"学生人数是"+stuList.size(),"结果",JOptionPane.PLAIN_MESSAGE);}elseif(value==6){flag=false;}}}staticpublicvoidprintVector(Vectoroutput){Stringline="";if(output.isEmpty())JOptionPane.showMessageDialog(null,"Thevecto
8、risempty","结果",JOptionPane.PLAIN_MESSAGE);else{Enumerationitems=output.elements();