标题:[求助]打印班级成绩表的问题
只看楼主
gxppa2006
Rank: 1
等 级:新手上路
帖 子:178
专家分:0
注 册:2007-2-27
 问题点数:0 回复次数:2 
[求助]打印班级成绩表的问题
//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
风月_无边
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:60
帖 子:2959
专家分:652
注 册:2007-1-19
得分:0 
以下是引用gxppa2006在2007-4-14 17:36:03的发言:
//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); 这样输出的是什么?
}
}
我想利用这个程序打印出班级的成绩表,但是用错误,不懂怎么改了,大家给帮下。谢谢了


我的网站 http://www.
2007-04-15 13:52



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-131854-1-1.html




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

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