java 不会了!求注释!类刚开始学!
//编写一个学生的类,//要求有姓名、年龄、兴趣、班级编号和一个教员类,//要求有姓名、教授课程、专业方向、教龄,//设计一个主方法,要求在主方法中调用这两个类。代码注释...
//编写一个学生的类,
//要求有姓名、年龄、兴趣、班级编号和一个教员类,
//要求有姓名、教授课程、专业方向、教龄,
//设计一个主方法,要求在主方法中调用这两个类。
代码注释!!!!谢谢! 展开
//要求有姓名、年龄、兴趣、班级编号和一个教员类,
//要求有姓名、教授课程、专业方向、教龄,
//设计一个主方法,要求在主方法中调用这两个类。
代码注释!!!!谢谢! 展开
展开全部
/**
* 学员类
* @author Pine
*
*/
class Student {
private String name;//姓名
private int age;//年龄
private String interest;//兴趣
private String classNo;//班级编号
//构造方法
public Student(String name, int age, String interest, String classNo) {
super();
this.name = name;
this.age = age;
this.interest = interest;
this.classNo = classNo;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getInterest() {
return interest;
}
public void setInterest(String interest) {
this.interest = interest;
}
public String getClassNo() {
return classNo;
}
public void setClassNo(String classNo) {
this.classNo = classNo;
}
}
/**
* 教员类
* @author Pine
*
*/
class 神察世Teacher {
private String name;//姓名
private int teacherAge;//教龄
private String major;//专业方向
private String course;//教授课程
//构造方法
public Teacher(String name, int teacherAge, String major, String course) {
super();
this.name = name;
this.teacherAge = teacherAge;
this.major = major;
this.course = course;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getTeacherAge() {
return teacherAge;
}
public void setTeacherAge(int teacherAge) {
this.teacherAge = 游肢teacherAge;
}
public String getMajor() {
return major;
}
public void setMajor(String major) {
this.major = major;
}
public String getCourse() {
return course;
}
public void setCourse(String course) {
this.course = course;
}
}
//测试方法
public static void main(String[] args) {
Student student = new Student("张三",18,"打篮球","CN001");
Teacher teacher = new Teacher("王老师",3,"计算机","没氏计算机概论");
}
展开全部
public class member{
public static void main(String args[]){
student stu=new student("alex","code","1");
teacher tea=new teacher("sublime"毕仿,"c program"手神纤瞎源,14,"coding");
stu.show();
tea.show();
}
}
class student{
public student(String name,String interest,String gradeId){
this.name=name;
this.interest=interest;
this.gradeId=gradeId;
}
String name;
String interest;
String gradeId;
public void show(){
System.out.println("student info:"+this.name+this.interest+this.gradeId);
}
}
class teacher{
public teacher(String name,String course, int age, String major){
this.name=name;
this.course=course;
this.age=age;
this.major=major;
}
String name;
String course;
int age;
String major;
public void show(){
System.out.println("teacher info:"+this.name+this.course+this.age+this.major);
}
}
public static void main(String args[]){
student stu=new student("alex","code","1");
teacher tea=new teacher("sublime"毕仿,"c program"手神纤瞎源,14,"coding");
stu.show();
tea.show();
}
}
class student{
public student(String name,String interest,String gradeId){
this.name=name;
this.interest=interest;
this.gradeId=gradeId;
}
String name;
String interest;
String gradeId;
public void show(){
System.out.println("student info:"+this.name+this.interest+this.gradeId);
}
}
class teacher{
public teacher(String name,String course, int age, String major){
this.name=name;
this.course=course;
this.age=age;
this.major=major;
}
String name;
String course;
int age;
String major;
public void show(){
System.out.println("teacher info:"+this.name+this.course+this.age+this.major);
}
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2015-11-16
展开全部
只提供思路:
1、新建一个学生类, private int id;private String name;private int age;........ 然后提供set、get方法;
2、新建一个教员类,同样如学生类那样设置基本字段信息;
3、主体方法可以是野码一个班级、或者是课程类,然后调用这两个类(一个班级或者课程里面可以有碧脊大多个学生、教员,调用的时候可以多new几个学生、教员,然后输出 某某悔竖班里面有哪些学生、每个课程有哪些教员等等)
1、新建一个学生类, private int id;private String name;private int age;........ 然后提供set、get方法;
2、新建一个教员类,同样如学生类那样设置基本字段信息;
3、主体方法可以是野码一个班级、或者是课程类,然后调用这两个类(一个班级或者课程里面可以有碧脊大多个学生、教员,调用的时候可以多new几个学生、教员,然后输出 某某悔竖班里面有哪些学生、每个课程有哪些教员等等)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询