定义一个父类Person,属性包含姓名、地址、城市、国家、邮编,方法包括构造方法、分别设置各个属性、分别返回各个属性、显示所有属性。Person子类有两个:学生类和教师类。
学生类自己的属性包括主修专业、学号、年级、成绩(成绩每名同学包括3门成绩),增加的方法包括设置和返回增加的属性,显示方法以及构造方法,
教师类自己的属性包括部门、收入,增加的方法包括设置和返回增加的属性,显示方法以及构造方法.
定义一个父类Person,属性包含姓名、地址、城市、国家、邮编,方法包括构造方法、分别设置各个属性、分别
答案:2 悬赏:40 手机版
解决时间 2021-02-03 10:05
- 提问者网友:捧腹剧
- 2021-02-02 10:40
最佳答案
- 五星知识达人网友:山河有幸埋战骨
- 2021-02-02 11:22
public class Person{
private String name;
private String address;
private String city;
public Person(){
}
}
private String name;
private String address;
private String city;
public Person(){
}
}
全部回答
- 1楼网友:怀裏藏嬌
- 2021-02-02 12:54
public class person {
private string name;
private string address;
private string city;
private string country;
private string postcode;
public person(string name, string address, string city, string country,
string postcode) {
this.name = name;
this.address = address;
this.city = city;
this.country = country;
this.postcode = postcode;
}
public string getname() {
return name;
}
public void setname(string name) {
this.name = name;
}
public string getaddress() {
return address;
}
public void setaddress(string address) {
this.address = address;
}
public string getcity() {
return city;
}
public void setcity(string city) {
this.city = city;
}
public string getcountry() {
return country;
}
public void setcountry(string country) {
this.country = country;
}
public string getpostcode() {
return postcode;
}
public void setpostcode(string postcode) {
this.postcode = postcode;
}
}
class student extends person{
public student(string name, string address, string city, string country,
string postcode) {
super(name, address, city, country, postcode);
}
}
class teacher extends person{
public teacher(string name, string address, string city, string country,
string postcode) {
super(name, address, city, country, postcode);
// todo auto-generated constructor stub
}
}
//参考一下吧
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯