實現一個名為Person的類和它的子類Employee,Employee有兩個子類Faculty 和Staff。


(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());
       

    }

}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM