简单写了些属性
package exe;
public class Person {
public int age;
public String name;
public int num;
public void sell(){
System.out.println("人具有卖东西的能力");
}
public void pay(){
System.out.println("人具有买东西的能力");
}
public void delivery(){
System.out.println("人具有送东西的能力");
}
}
package exe;
public class Seller extends Person {
public static void main(String[] args) {
Seller seller =new Seller();
seller.age=43;
seller.name="徐虎";
seller.num=8894;
seller.sell();
}
}
package exe;
public class Student extends Person {
public static void main(String[] args) {
Student student=new Student();
student.age=18;
student.name="小明";
student.num=01;
student.pay();
}
}
package exe;
public class Courier extends Person {
public static void main(String[] args) {
Courier courier=new Courier();
courier.age=25;
courier.name="张三";
courier.num=345;
courier.delivery();
}
}
class Person{
private String name;
private int age;
public void setName(String name){
this.name = name;
}
public String getName(){
return name;
}
}
class Students extends person{
private String school;
private double banji;//班级
public String getSchool(){
return school;
}
public void setSchool(String school){
this.school = school;
}
}
售货员还有快递员类跟学生类代码差不多格式
class Person{
private String name;
private String add;
private int age;
}
class Stu extends Person{
private int height;
private double tizhong;
}
class Saler extends Person{
//类似上面
}
class Kder extends Person{
}