java代码:系统至少应包括以下信息: 学生信息:学号、姓名、性别、年级、密码 课程信息:课程编号、课程名称、已选人数、可选人数、授课教师。
时间: 2023-07-10 18:31:39 浏览: 73
好的,您的要求已经被记录了。以下是一个简单的 Java 代码示例,用于管理学生和课程信息:
```
public class Student {
private String id;
private String name;
private String gender;
private String grade;
private String password;
// 构造函数
public Student(String id, String name, String gender, String grade, String password) {
this.id = id;
this.name = name;
this.gender = gender;
this.grade = grade;
this.password = password;
}
// getter 和 setter 方法
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
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 String getGrade() {
return grade;
}
public void setGrade(String grade) {
this.grade = grade;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
public class Course {
private String id;
private String name;
private int selectedNum;
private int maxNum;
private String teacher;
// 构造函数
public Course(String id, String name, int selectedNum, int maxNum, String teacher) {
this.id = id;
this.name = name;
this.selectedNum = selectedNum;
this.maxNum = maxNum;
this.teacher = teacher;
}
// getter 和 setter 方法
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getSelectedNum() {
return selectedNum;
}
public void setSelectedNum(int selectedNum) {
this.selectedNum = selectedNum;
}
public int getMaxNum() {
return maxNum;
}
public void setMaxNum(int maxNum) {
this.maxNum = maxNum;
}
public String getTeacher() {
return teacher;
}
public void setTeacher(String teacher) {
this.teacher = teacher;
}
}
public class Main {
public static void main(String[] args) {
// 创建一个学生对象
Student student = new Student("001", "张三", "男", "一年级", "123456");
// 创建一个课程对象
Course course = new Course("001", "Java编程", 0, 50, "李老师");
// 输出学生和课程信息
System.out.println("学生信息:");
System.out.println("学号:" + student.getId());
System.out.println("姓名:" + student.getName());
System.out.println("性别:" + student.getGender());
System.out.println("年级:" + student.getGrade());
System.out.println("密码:" + student.getPassword());
System.out.println("课程信息:");
System.out.println("课程编号:" + course.getId());
System.out.println("课程名称:" + course.getName());
System.out.println("已选人数:" + course.getSelectedNum());
System.out.println("可选人数:" + course.getMaxNum());
System.out.println("授课教师:" + course.getTeacher());
}
}
```
这段代码定义了一个 `Student` 类和一个 `Course` 类,分别用于存储学生和课程信息。在 `Main` 类中,我们创建了一个学生对象和一个课程对象,并输出它们的信息。您可以根据需要扩展这个代码,以便更好地管理学生和课程信息。
阅读全文