标签:
1、实现一个名为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 text11; 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 text11; 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 text11; 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 text11; public class Staff extends Employee { private String duty; public String getDuty() { return duty; } public void setDuty(String duty) { this.duty = duty; } } package text11; public class Test { public static void main(String[] args) { Faculty a=new Faculty(); a.setName("张三"); a.setAddress("张店区共青团路1号"); a.setEmail("12345877@qq.com"); a.setOffice("富丽商城A座407"); a.setWage(4700); a.setHiredate("2013年4月1日"); a.setTelphone("123456788"); a.setDegree("本科"); a.setLevel("一级"); System.out.println("员工姓名:"+a.getName()+"\r\n"+"地址:"+a.getAddress()+"\r\n"+"e-mail:"+ a.getEmail()+"\r\n"+"地址:"+a.getOffice()+"\r\n"+"工资:"+a.getWage()+"\r\n"+"入职时间:"+a.getHiredate()+ "\r\n"+"电话:"+a.getTelphone()+"\r\n"+"学位:"+a.getDegree()+"\r\n"+"级别:"+a.getLevel()); Staff b=new Staff(); b.setName("李四"); b.setAddress("张店区共人民路1号"); b.setEmail("12345557@qq.com"); b.setOffice("银座商城4楼4407"); b.setWage(5500); b.setHiredate("2013年5月1日"); b.setTelphone("123555588"); b.setDuty("优秀员工"); System.out.println("员工姓名:"+b.getName()+"\r\n"+"地址:"+b.getAddress()+"\r\n"+"e-mail:"+ b.getEmail()+"\r\n"+"地址:"+b.getOffice()+"\r\n"+"工资:"+b.getWage()+"\r\n"+"入职时间:"+b.getHiredate()+ "\r\n"+"电话:"+b.getTelphone()+"\r\n"+"职务等级:"+b.getDuty()); } }
标签:
原文地址:http://www.cnblogs.com/wangguoning/p/5893945.html