java定义一个课程类,属性有:课程号、课程名、课程性质、学时、学分
时间: 2023-10-15 21:04:57 浏览: 52
好的,您可以定义一个Java课程类,以下是参考代码:
public class Course {
private String courseId;
private String courseName;
private String courseProperty;
private int classHours;
private double credit;
public Course(String courseId, String courseName, String courseProperty,
int classHours, double credit) {
this.courseId = courseId;
this.courseName = courseName;
this.courseProperty = courseProperty;
this.classHours = classHours;
this.credit = credit;
}
public String getCourseId() {
return courseId;
}
public String getCourseName() {
return courseName;
}
public String getCourseProperty() {
return courseProperty;
}
public int getClassHours() {
return classHours;
}
public double getCredit() {
return credit;
}
}
请注意,这只是一种参考实现方式,您可以根据实际需要自行更改属性类型和名称,或根据具体业务需求添加其他属性和方法。