码迷,mamicode.com
首页 > 其他好文 > 详细

实现一个名为Person的类和它的子类Employee,Employee有两个子类Faculty 和Staff。

时间:2016-09-20 19:44:02      阅读:1592      评论:0      收藏:0      [点我收藏+]

标签:

(1)Person类中的属性有:姓名name(String类型),地址address(String类型),

电话号码telphone(String类型)和电子邮件地址email(String类型);

(2)Employee类中的属性有:办公室office(String类型),工资wage(double

类型),受雇日期hiredate(String类型);

(3)Faculty类中的属性有:学位degree(String类型),级别level(String类型);

(4)Staff类中的属性有:职务称号duty(String类型)。

 

package com.chuoji.text01;

public class Person {

        private String name;
        private String address;
        private String telphone;
        private String email;
        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 getTelphone() {
            return telphone;
        }
        public void setTelphone(String telphone) {
            this.telphone = telphone;
        }
        public String getEmail() {
            return email;
        }
        public void setEmail(String email) {
            this.email = email;
        }
        
    }
    
    
package com.chuoji.text01;

public class Employee extends Person {
    
    
        private String office;
        private double wage;
        private String hiredate;
        
        
        public String getOffice() {
            return office;
        }
        public void setOffice(String office) {
            this.office = office;
        }
        public double getWage() {
            return wage;
        }
        public void setWage(double wage) {
            this.wage = wage;
        }
        public String getHiredate() {
            return hiredate;
        }
        public void setHiredate(String hiredate) {
            this.hiredate = hiredate;
        }
        
    }
package com.chuoji.text01;

public class Faculty extends Employee {
    
    private String degree;
    private String level;
    public String getDegree() {
        return degree;
    }
    public void setDegree(String degree) {
        this.degree = degree;
    }
    public String getLevel() {
        return level;
    }
    public void setLevel(String level) {
        this.level = level;
    }
    
    

}
package com.chuoji.text01;

public class Staff {
    
    private String duty;

    public String getDuty() {
        return duty;
    }

    public void setDuty(String duty) {
        this.duty = duty;
    }
    
    
    

}
package com.chuoji.text01;

public class ceshi {

    public static void main(String[] args) {

        Faculty a=new Faculty();
        a.setName("小张");
        a.setTelphone("18463080600");
        a.setDegree("本科");
        a.setLevel("一级");
        a.setEmail("33695422@qq.com");
       
        System.out.println("员工姓名:"+a.getName()+" 电话:"+a.getTelphone());
        System.out.println(" 学位:"+a.getDegree()+" 级别:"+a.getLevel()+" 邮箱:"+a.getEmail());
       

    }

}

技术分享

实现一个名为Person的类和它的子类Employee,Employee有两个子类Faculty 和Staff。

标签:

原文地址:http://www.cnblogs.com/chouji717/p/5889922.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!