payroll system
来源:互联网 发布:人工智能对人类威胁 编辑:程序博客网 时间:2024/05/29 05:05
这个学期《面向对象技术》课程设计比较有意思,给我安排的是一个工资表系统。
以前没学过JAVA,这次正好趁这个机会好好实践一下。
本来想好好做的,不过由于杂事太多,而且要翻译一个死长死长的论文,所以本来真正要好好做的东西没有留下时间做 。
以下是我的部分代码,只是对该系统的一个初步设计
//雇员抽象类
public abstract class Employee
{
private String Name;
private String Password;
public Employee(String name)
{
Name = name;
}
public String getName() {return Name;}
public String toString()
{
return Name;
}
public abstract double earnings();
}
//佣金型雇员
public final class CommissionEmployee extends Employee
{
// private double salary;
private double commissionrate;
private double commission;
private int quantity;
public CommissionEmployee(String name, double c, int choice, int q)
{
super(name);
// setSalary(s);
setCommissionrate(choice);
setCommission(c);
setQuantity(q);
}
// public void setSalary(double s)
// {salary = (s > 0 ? s : 0);}
public void setQuantity(int q)
{quantity = (q > 0 ? q : 0);}
public void setCommissionrate(int choice)
{
switch(choice){
case 1:
commissionrate = 0.10;
break;
case 2:
commissionrate = 0.15;
break;
case 3:
commissionrate = 0.25;
break;
default:
commissionrate = 0.35;
}
}
public void setCommission(double c)
{commission = (c > 0 ? c : 0);}
public double earnings()
{return commission * commissionrate * quantity;}
public String toString()
{
return "CommissionEmployee:" + super.toString();
}
}
//月薪制雇员
public final class FlatSalaryEmployee extends Employee
{
private double monthlySalary;
public FlatSalaryEmployee(String name,double s)
{
super(name);
setMonthlySalary(s);
}
public void setMonthlySalary(double s)
{monthlySalary = (s > 0 ? s: 0);}
public String toString()
{
return "FlatSalaryEmployee:" + super.toString();
}
public double earnings() {return monthlySalary;}
}
//小时计费型雇员
public final class HourlyEmployee extends Employee{
private double wage;
private double hours;
public HourlyEmployee(String name, double w, double h)
{
super(name);
setWage(w);
setHours(h);
}
public void setWage(double w)
{wage = (w > 0 ? w : 0);}
public void setHours(double h)
{hours = (h >= 0 && h < 168 ? h : 0);}
public double earnings()
{
if (hours < 8)
return wage * hours * 5;
else
return (wage * 8 + 1.5 * wage * (hours - 8)) * 5;
}
public String toString()
{
return "HourlyEmployee:" + super.toString();
}
}
//主程序
import javax.swing.JOptionPane;
import java.text.DecimalFormat;
public class PayrollTest {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Employee ref;
String output = "";
FlatSalaryEmployee f =
new FlatSalaryEmployee("John Smith", 3000.00);
HourlyEmployee h =
new HourlyEmployee("Karen Price", 20.50, 10);
CommissionEmployee c =
new CommissionEmployee("Sue Jones", 3.0, 3, 1500);
DecimalFormat precision2 = new DecimalFormat("0.00");
ref = f;
output += ref.toString() + " earned $" +
precision2.format(ref.earnings()) + "/n" +
f.toString() + " earned $" +
precision2.format(f.earnings()) + "/n";
ref = c;
output += ref.toString() + " earned $" +
precision2.format(ref.earnings()) + "/n" +
c.toString() + " earned $" +
precision2.format(c.earnings()) + "/n";
ref = h;
output += ref.toString() + " earned $" +
precision2.format(ref.earnings()) + "/n" +
h.toString() + " earned $" +
precision2.format(h.earnings()) + "/n";
JOptionPane.showMessageDialog(null, output,
"Payroll",
JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
}
- payroll system
- 薪水册测试类及结果(Payroll System modification)
- change payroll status
- Payroll & Time Management
- Information on Payroll Taxes
- Payroll Problems Plague $25M PeopleSoft Rollout
- HR开发 GET PAYROLL 获取读取员工工资
- Job Information页面上影响Payroll计算的字段
- 对于CN Payroll我的一些个人理解
- GET PAYROLL 用逻辑数据库开发HR报表
- SAP HR Schema 详解(一)Payroll schema基础
- system
- System
- system
- system
- system
- System
- System
- Struts执行过程,面试时可用
- 系分--0811系分冲刺(群) 通过系分或项管报喜!
- ultraedit 中verilog的语法高亮
- 系分--擦肩而过
- 使用DOM4J来生成一个XML文件(一)
- payroll system
- 来到了哥新家
- DOM和SAX之间的差异
- OO设计原则总结
- 23种经典设计模式摘要
- 经典的ERP解决方案---三个和尚抬水吃的ERP解决方案
- SQL各种连接学习
- 求职毕业生们的十条忠告
- 人总是会遇到挫折的