
已解决问题
谷歌bayogiant用户在2014.10.22提交了关于“杜甫J**a二维数组输出成绩”的提问,欢迎大家涌跃发表自己的观点。目前共有1个回答,最后更新于2024-07-28T20:44:08。希望大家能够帮助她。详细问题描述及疑问:期待您的答案,真心佩服你,谢谢 !
详细问题描述及疑问:期待您的答案,真心佩服你,谢谢 !
packageclient;
importj**a.a
importj**a.
importj**a.awt.ev
importj**ax.swing.JButton;
importj**ax.swi
importj**ax
importj**ax.swing.JLabel;
importj
im
publicclassstudentimplementsActionListener{
pri
pr
privateJLabelname,course;
privateJC
privateJButtonok;
privatescorethe
publicstudent(){
jf=newJFrame();
jp=n
name=n
course=newJLabel("科
jp.setLayout(newGridLayout(3,2));
S
StringtheCourse[
name1=newJComboBox(t
course1=newJComboBox(t
ok=newJButton("查询");
ok.addActionListener
jp.add(name);
jp.add(name1);
jp.add(course);
jp.add(course1);
jp.add(ok);
jf.setLayout(newGridLayout
jf.add(jp);
j
jf.setLo
jf.setVisible(true);
jf.setDefaultCloseOper
}
publicv
{
this.theScore[
thi
this
}
publicstaticvoidmain(String[]args){
studentstu=newstudent();
stu.inputData();
}
@Override
publicvoidactionPerformed(ActionEvente){
//TODOAuto-generatedmethodstub
if(e.getSource()==ok){
Stringcontent="";
if(***.name1.getSelectedIndex()==3)//输出全部人的
{
if(this.course1.getSelectedIndex()==3)//全部分数
{
content+="姓名数学英语计算机\n";
for(inti=0;i<this.theScore.length;i++){
content+=(this.theScore[i].getName()+""
+this.theScore[i].getMath()+""
+this.theScore[i].getEnglish()+""
+this.theScore[i].getComputer()+"\n");
}
JOptionPane.showMessageDialog(**ll,content);
return;
}else{
if(this.course1.getSelectedIndex()==0){
content+="姓名数学\n";
for(inti=0;i<this.theScore.length;i++){
content+=(this.theScore[i].getName()+""
+this.theScore[i].getMath()+"\n");
}
}elseif(this.course1.getSelectedIndex()==1){
content+="姓名英语\n";
for(inti=0;i<this.theScore.length;i++){
content+=(this.theScore[i].getName()+""
+this.theScore[i].getEnglish()+"\n");
}
}else{
content+="姓名计算机\n";
for(inti=0;i<this.theScore.length;i++){
content+=(this.theScore[i].getName()+""
+this.theScore[i].getComputer()+"\n");
}
}
JOptionPane.showMessageDialog(**ll,content);
return;
}
}
//System.out.println("nameindex="+name1.getSelectedIndex()+"courseindex="+course1.getSelectedIndex());
else{
if(this.course1.getSelectedIndex()==3){
content+="姓名数学英语计算机\n";
intindex=***.name1.getSelectedIndex();
content+=(this.theScore[index].getName()+""
+this.theScore[index].getMath()+""
+this.theScore[index].getEnglish()+""
+this.theScore[index].getComputer()+"\n");
JOptionPane.showMessageDialog(**ll,content);
return;
}else{
inti=***.name1.getSelectedIndex();
if(this.course1.getSelectedIndex()==0){
content+="姓名数学\n";
content+=(this.theScore[i].getName()+""
+this.theScore[i].getMath()+"\n");
}elseif(this.course1.getSelectedIndex()==1){
content+="姓名英语\n";
content+=(this.theScore[i].getName()+""
+this.theScore[i].getEnglish()+"\n");
}else{
content+="姓名计算机\n";
content+=(this.theScore[i].getName()+""
+this.theScore[i].getComputer()+"\n");
}
JOptionPane.showMessageDialog(**ll,content);
return;
}
}
}
}
}
classscore{//保存每**的类
privateStringname;
privatefloatMath;
privatefloatEnglish;
privatefloatComputer;
publicStringgetName(){
returnname;
}
publicvoidsetName(Stringname){
***.name=name;
}
publicfloatgetMath(){
returnMath;
}
publicvoidsetMath(floatmath){
Math=math;
}
publicfloatgetEnglish(){
returnEnglish;
}
publicvoidsetEnglish(floatenglish){
English=english;
}
publicfloatgetComputer(){
returnComputer;
}
publicvoidsetComputer(floatcomputer){
Computer=computer;
}
publicscore(Stringname,floatMath,floatEnglish,floatComputer){
***.name=name;
this.Math=Math;
this.English=English;
***.Computer=Computer;
}
}
=================