| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 538 人关注过本帖
标题:[求助]打印班级成绩表的问题
取消只看楼主 加入收藏
gxppa2006
Rank: 1
等 级:新手上路
帖 子:178
专家分:0
注 册:2007-2-27
收藏
 问题点数:0 回复次数:1 
[求助]打印班级成绩表的问题
//homework_student.java
public class homework_student
{
private String name;
private int age;
private char sex;
private String stuid;
private String[] course_names;
private double[] course_scores;
public String getName()
{
return name;
}
public void setName(String n)
{
name=n;
}
public int getAge()
{
return age;
}
public void setAge(int a)
{
age=(a>0&&a<120)?a:0;
}
public char getSex()
{
return sex;
}
public void setSex(char s)
{
sex=(s=='F'||s=='M')?s:'M';
}
public String getStuid()
{
return stuid;
}
public void setStuid(String si)
{
stuid=si;
}
public String[] getCourse_name()
{
return course_names;
}
public void setCourse_name(String[] cn)
{
course_names=cn;
}
public String getCourse_names(int i)
{
return course_names[i];
}
public void setCourse_name(int i,String cn)
{
course_names[i]=cn;
}
public double[] getCourse_score()
{
return course_scores;
}
public void setCourse_score(double[] cs)
{
course_scores=cs;
}
public double getCourse_score(int i)
{
return course_scores[i];
}
public void setCourse_score(int i,double cs)
{
course_scores[i]=cs;
}
public String toString()
{
String temp="=================================================%nname:"+name+"%n";
temp+="sex:"+sex+"%n";
for(int i=0;i<course_names.length;i++)
{
temp+=course_names[i]+":"+course_scores[i]+"%n";
}
temp+="==================================================";
return temp;
}
public boolean equals(homework_student s)
{
return name.equals(s.getName())&&stuid.equals(s.getStuid());
}

}
上面这个是用来定义一个同学的信息
//home_class.java
public class homework_class
{
private String class_name;
private String class_mailbox;
private String class_master;
private String class_envent;
private static int class_account;
private homework_student[] all_student;
public String getClass_name()
{
return class_name;
}
public void setClass_name(String n)
{
class_name=n;
}
public String getClass_maser()
{
return class_master;
}
public void setClass_master(String cm)
{
class_master=cm;
}
public String getClass_mailbox()
{
return class_mailbox;
}
public void setClass_mailbox(String cm)
{
class_mailbox=cm;
}
public String getClass_event()
{
return class_envent;
}
public void setClass_event(String ce)
{
class_envent=ce;
}
public int getClass_account()
{
return class_account;
}
public void setClass_acccount(int a)
{
class_account=(a>0)?a:0;
}
public homework_student[] getAll_student()
{
return all_student;
}
public void setAll_student(homework_student[] as)
{
all_student=as;
}
public homework_student getAll_student(int i)
{
return all_student[i];
}
public void setAll_student(int i,homework_student as)
{
all_student[i]=as;
}
public String toString()
{
String temp;
temp="====================================================%n";
temp+=class_envent+"%n";
if(class_master.length()!=0)
{
temp+=class_master+"%n";
}
for(int i=0;i<all_student.length;i++)
{
temp+=all_student[i].getCourse_name();
temp+=all_student[i].getCourse_score();
temp+="%n";
}
temp+="====================================================%n";
return temp;
}
public boolean equals(int i,homework_student[] all)
{
return all[i].equals(all_student[i].getCourse_name())&&all[i].equals(all_student[i].getCourse_score());
}
}
上面这个是定义一个班级
//homework_student_test.java
import java.util.*;
public class homework_student_test
{
public static void main(String[] args)
{
homework_class a=new homework_class();
homework_student b=new homework_student();
String[] str=new String[2];
str[0]="Java";
double[] dor=new double[2];
dor[0]=100;
homework_student[] hs=new homework_student[2];
hs[0]=b;
b.setAge(18);
b.setName("gxppa2006");
b.setCourse_name(str);
b.setCourse_score(dor);
b.setSex('M');
b.setStuid("320050932621");
a.setAll_student(hs);
a.setClass_acccount(2);
a.setClass_event("成绩表");
a.setClass_mailbox("160信箱835分箱");
a.setClass_master("老苗");
a.setClass_name("计算机");
System.out.println(a);
}
}
我想利用这个程序打印出班级的成绩表,但是用错误,不懂怎么改了,大家给帮下。谢谢了
搜索更多相关主题的帖子: String public private name 打印 
2007-04-14 17:36
gxppa2006
Rank: 1
等 级:新手上路
帖 子:178
专家分:0
注 册:2007-2-27
收藏
得分:0 
55555 怎么没有人帮帮我啊

临渊羡鱼,不如退而结网!
2007-04-15 11:25
快速回复:[求助]打印班级成绩表的问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.024724 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved