定义一个学生类(Student),属性包括:学号,班号,姓名,性别,年龄,班级总人数
方法包括:获得学号,获得班号,获得姓名,获得性别,获得年龄,获得班级总人数,修改学号,修改班号,修改姓名,修改性别,修改年龄以及一个toString()方法将Studen...
方法包括:获得学号,获得班号,获得姓名,获得性别,获得年龄,获得班级总人数,修改学号,修改班号,修改姓名,修改性别,修改年龄以及一个toString()方法将Student类中的所有属性组合成一个字符串。定义一个学生数组对象。当在页面上填写完成并点击“完成”按钮以后,根据输入的值创建一个Student对象,并调用PrintInfo方法将对象的信息输出到窗口中的文本区域中。
展开
4个回答
展开全部
public class Test
{
public static void main (String[] args) {
Student[] students = new Student[] {
new Student("123", "456", "abc", "male", 10, 20),
new Student("789", "000", "def", "female", 30, 40)
};
for (Student s : students) {
System.out.println(s);
}
}
}
class Student {
String studentId, classId, name, gender;
int age, studentCount;
public Student(String studentId, String classId, String name,
String gender, int age, int studentCount) {
this.studentId = studentId;
this.classId = classId;
this.name = name;
this.gender = gender;
this.age = age;
this.studentCount = studentCount;
}
public String getStudentId() {
return studentId;
}
public void setStudentId(String studentId) {
this.studentId = studentId;
}
public String getClassId() {
return classId;
}
public void setClassId(String classId) {
this.classId = classId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public int getStudentCount() {
return studentCount;
}
public void setStudentCount(int studentCount) {
this.studentCount = studentCount;
}
@Override
public String toString() {
return "Student [studentId=" + studentId + ", classId=" + classId
+ ", name=" + name + ", gender=" + gender + ", age=" + age
+ ", studentCount=" + studentCount + "]";
}
}
{
public static void main (String[] args) {
Student[] students = new Student[] {
new Student("123", "456", "abc", "male", 10, 20),
new Student("789", "000", "def", "female", 30, 40)
};
for (Student s : students) {
System.out.println(s);
}
}
}
class Student {
String studentId, classId, name, gender;
int age, studentCount;
public Student(String studentId, String classId, String name,
String gender, int age, int studentCount) {
this.studentId = studentId;
this.classId = classId;
this.name = name;
this.gender = gender;
this.age = age;
this.studentCount = studentCount;
}
public String getStudentId() {
return studentId;
}
public void setStudentId(String studentId) {
this.studentId = studentId;
}
public String getClassId() {
return classId;
}
public void setClassId(String classId) {
this.classId = classId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public int getStudentCount() {
return studentCount;
}
public void setStudentCount(int studentCount) {
this.studentCount = studentCount;
}
@Override
public String toString() {
return "Student [studentId=" + studentId + ", classId=" + classId
+ ", name=" + name + ", gender=" + gender + ", age=" + age
+ ", studentCount=" + studentCount + "]";
}
}
展开全部
别白费劲了,问这种问题。想让别人帮你写作业还是什么的。想要提高要带这问题来,不是什么都让别人来做,自享其成。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
我会说你算一个学编程的不,这个不会,不会创建类名?不会写方法?学生对象是类还是用结构创建?tostring()方法不会?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
班级总人数这个属性很怪
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询