java题目求解

1、  编写Employee类,成员变量:name,age,tel,gz,并为其添加相应的set和get方法, 1个方法:aiseSalary(double proportion):涨工资方法。
2.编写Manager类,该类继承于的Employee类
(1)为其添加:
                   两个属性:办公室officeID和年终分红bonus;
                   1构造器方法:带有5个参数的构造器方法,用于对除bonus属性外的所有其它属性进行初始化;
                   方法:officeID属性和bonus属性的相关set和get方法;
         (2)重写Employee类中的方法raiseSalary(double proportion),经理涨工资的计算方法为在雇员工资涨幅的基础上增加10%的比例。
3.编写TemporaryEmployee(临时工)类,该类继承于Employee类
         (1)为其添加:
                    1个属性:雇佣年限hireYears;
                    构造器方法:用于初始化该类的所有属性;
                    方法:hireYears属性的set和get方法;

(2)重写Employee类中的方法raiseSalary(double proportion),临时工的工资涨幅为正式雇员的50%。

public class Employee {
	//name,age,tel,gz
	String name;
	int age;
	String tel;
	double gz;

public Employee() {
	}
	
	/*
	* 涨工资方法
	* */
	public void raiseSalary(double proportion){
		this.setGz(this.gz+proportion);
	}
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getAge() {
		return age;
	}
	public void setAge(int age) {
		this.age = age;
	}
	public String getTel() {
		return tel;
	}
	public void setTel(String tel) {
		this.tel = tel;
	}
	public double getGz() {
		return gz;
	}
	public void setGz(double gz) {
		this.gz = gz;
	}
	
}
------------------------------------------------------------------
public class Manager extends Employee {
	private String officeID;// 此处不了解你的办公室具体ID生成策略,用String类型
	private double bonus;

	public Manager() {
		// 实体类的空参数构造方法(java bean)
	}

	public Manager(String name, int age, String tel, double gz, String officeID) {
		this.name = name;
		this.age = age;
		this.tel = tel;
		this.gz = gz;
		this.officeID = officeID;
	}
	
	/*
	* 重写涨工资方法
	* */
	public void raiseSalary(double proportion){
		this.setGz(this.gz+proportion*1.1);
	}

	public String getOfficeID() {
		return officeID;
	}

	public void setOfficeID(String officeID) {
		this.officeID = officeID;
	}

	public double getBonus() {
		return bonus;
	}

	public void setBonus(double bonus) {
		this.bonus = bonus;
	}
}
-------------------------------------------------------------------

public class TemporaryEmployee extends Employee {
	private int hireYears;
	
	public TemporaryEmployee(){
		
	}
	public TemporaryEmployee(String name, int age, String tel, double gz,int hireYears){
		this.name = name;
		this.age = age;
		this.tel = tel;
		this.gz = gz;
		this.hireYears = hireYears;
	}
	
	/*
	* 重写涨工资方法
	* */
	public void raiseSalary(double proportion) {
		this.setGz(this.gz+proportion*0.5);
	}
	
	public int getHireYears() {
		return hireYears;
	}
	public void setHireYears(int hireYears) {
		this.hireYears = hireYears;
	}

}

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值