java编程代码,要完整的代码,可以运行出来的。谢谢!
编写程序片段,定义表示课程的类Course。课程的属性包括课程名、编号、先修课号;方法包括设置课程名、设置编号、设置先修课号以及获取课程名、获取编号、获取先修课号...
编写程序片段,定义表示课程的类Course。课程的属性包括课程名、编号、先修课号;方法包括设置课程名、设置编号、设置先修课号以及获取课程名、获取编号、获取先修课号
展开
2个回答
展开全部
Course.java
public class Course {
private String name;//课程名
private String id; //编号
private String selectId; //选修课编号
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getSelectId() {
return selectId;
}
public void setSelectId(String selectId) {
this.selectId = selectId;
}
}
追答
把这个类里点击运行
TestCource.java
public class TestCource {
public static void main(String[] args) {
Course c = new Course();
c.setId("bianhao");
c.setName("mingzi");
c.setSelectId("xuanxiubianhao");
System.out.println(c.getId());
System.out.println(c.getName());
System.out.println(c.getSelectId());
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
public class Course {
private String kechengming;
private String bianhao;
private String xuanxiuke;
public String getKechengming() {
return kechengming;
}
public void setKechengming(String kechengming) {
this.kechengming = kechengming;
}
public String getBianhao() {
return bianhao;
}
public void setBianhao(String bianhao) {
this.bianhao = bianhao;
}
public String getXuanxiuke() {
return xuanxiuke;
}
public void setXuanxiuke(String xuanxiuke) {
this.xuanxiuke = xuanxiuke;
}
}
课程Course类
追答
public class Course {
private String kechengming;
private String bianhao;
private String xuanxiuke;
public String getKechengming() {
return kechengming;
}
public void setKechengming(String kechengming) {
this.kechengming = kechengming;
}
public String getBianhao() {
return bianhao;
}
public void setBianhao(String bianhao) {
this.bianhao = bianhao;
}
public String getXuanxiuke() {
return xuanxiuke;
}
public void setXuanxiuke(String xuanxiuke) {
this.xuanxiuke = xuanxiuke;
}
public static void main(String[] args) {
Course c = new Course();
c.setKechengming("课程名");
c.setBianhao("编号");
c.setXuanxiuke("选修课");
System.out.println(c.getKechengming());
System.out.println(c.getBianhao());
System.out.println(c.getXuanxiuke());
}
}
上面是定义的普通类,如果要调用测试的话,需要加入main方法去创建使用
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询