• Java作业5.17


    package mmm;
    
    public class ColaEmployee {
    	String name;
    	int month;
    
    	public ColaEmployee() {
    
    	}
    
    	public ColaEmployee(String name, int month) {
    		super();
    		this.name = name;
    		this.month = month;
    	}
    
    	public double getSalary(int month) {
    		return 0;
    	}
    }
    package mmm;
    
    public class SalariedEmployee extends ColaEmployee {
    	  double n;
    
    	    public SalariedEmployee(String name, int month, double n) {
    	        super(name, month);
    	        this.n = n;
    	    }
    
    	    public double getSalary(int month) {
    	        if (super.month == month) {
    	            return n + 100;
    	        } else {
    	            return n;
    	        }
    	    }
    
    	}
    package mmm;
    
    public class HourlyEmployee extends ColaEmployee {
    	private int a;
    	private int b;
    
    	public HourlyEmployee(String name1, int month, int a1, int b1) {
    		super();
    		this.name=name1;
    		this.b = b1;
    		this.a = a1;
    	}
    
    	public double getSalary(int month) {
    		if (super.month == month) {
    			if (b > 160) {
    				return a * 160 + a * (b - 160) * 1.5 + 100;
    			} else {
    				return a + b + 100;
    			}
    		} else {
    			if (b > 160) {
    				return a * 160 + a * (a - 160) * 1.5;
    			} else {
    				return a * b;
    			}
    		}
    	}
    
    }
    package mmm;
    
    public class SalesEmployee extends ColaEmployee {
    	private int yx;
    	private double m;
    
    	public SalesEmployee(String name, int month, int yx, double m) {
    		super(name, month);
    		this.yx = yx;
    		this.m = m;
    	}
    
    	public double getSalary(int month) {
    		if (super.month == month) {
    			return yx * m + 100;
    		} else {
    			return yx * m;
    		}
    	}
    
    }
    package mmm;
    
    public class Company {
    	 public void getSalary(ColaEmployee c, int month) {
    	        System.out.println(c.name + " 在" + month + "月的月工资数额为 " + c.getSalary(month) + "元");
    	    }
    }
    package mmm;
    
    public class TextCompany {
    
    	public static void main(String[] args) {
    	        ColaEmployee[] m = { new SalariedEmployee("固定员工", 4, 100), new HourlyEmployee("小时工",8,300,100),
    	                new SalesEmployee("销售额和提成的", 4, 2000, 0.3) };
    	        for (int i = 0; i < m.length; i++) {
    	            new Company().getSalary(m[i], 10);
    	        }
    	    }
    
    }
    

      

      

  • 相关阅读:
    poj2752Seek the Name, Seek the Fame【kmp next数组应用】
    poj1961Period【kmp next数组】
    poj2406(kmp next数组)
    KMP原理
    0529
    0428
    2045年4月25日
    0421
    黄金连分数【大数】
    学习linux内核时常碰到的汇编指令(1)
  • 原文地址:https://www.cnblogs.com/hzpiou/p/12918817.html
Copyright © 2020-2023  润新知