private double salary;
/**
* 无参数构造函数
*/
public Employee() {
}
/**
* 给属性赋值构造函数
* @param number
* @param name
* @param salary
*/
public Employee(String number, String name, double salary) {
super();
this.number = number;
this.name = name;
this.salary = salary;
}
public static void main(String[] args) {
//员工一,并且构造函数里设置值
Employee e1 = new Employee("e0001", "xiaoming", 5000.0);
System.out.println("员工一:" + e1);
//员工二,用set设置值,get的话可以获取到员工某个属性
Employee e2 = new Employee();
e2.setName("小二");
e2.setNumber("e0002");
e2.setSalary(5500.1);
System.out.println("员工二:" + e2);
}
public String getNumber() {
return number;
}
public void setNumber(String number) {
this.number = number;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getSalary() {
return salary;
}
public void setSalary(double salary) {
this.salary = salary;
}
@Override
public String toString() {
return "Employee [number=" + number + ", name=" + name + ", salary=" +
salary + "]";
}
}
运行结果:
员工一:Employee [number=e0001, name=xiaoming, salary=5000.0]
员工二:Employee [number=e0002, name=小二, salary=5500.1]
java程序设计,多态在工资系统中的应用 。请将【代码一】到【代码六】用为Java源代码填写代码一:
private Double weeklySalary;
代码二:
public void setWeeklySalary(Double weeklySalary){
this.weeklySalary=weeklySalary;
}
代码三:
private Double salary;
private Integer piece;
public PieceWorker (String name,Integer p,Double s) {
super(name);
setSalary(s);
setPiece(p);
}
public void setPiece(Integer p){
this.piece=p;
}
public void setSalary(Double s){
this.salary=s;
}
public double earnings() {
return piece*salary;
}
代码四:
private Double salary;
private Integer hour;
public PieceWorker (String name,Integer h,Double s) {
super(name);
setSalary(s);
setHour(h);
}
public void setHour(Integer h){
this.hour=h;
}
public void setSalary(Double s){
this.salary=s;
}
public double earnings() {
return h*salary;
}
求助java设计 - 企业员工工资管理系统的源代码和运行效果截图作为一个学生 , 需要增强自己的动手能力哦,不然这样的设计会变得毫无用处 。下面这个可以学习下
网页链接
使用Java语言编写程序 , 输出某公司员工的基本信息public class Test0 {
public static void main(String[] args) {
Employee ZhangSan = new Employee("001", "张三", '男', "销售部", 6000, 1000, "普通员工");
Employee LiSi = new Employee("002", "李四", '女', "人事部", 7000, 2000, "超级员工");
System.out.println(ZhangSan.toString()); //打印张三信息
System.out.println(LiSi.toString()); //打印李四信息
}
}
class Employee{
private String id; //员工ID
private String name; //姓名
private char sex; //性别
private String department;//部门
private int basic_salary;//基本工资
private int extra_salary;//薪金
private String classify;//类别
/**
* 构造方法
*/
public Employee(String id, String name, char sex, String department,
int basic_salary, int extra_salary, String classify) {
this.id = id;
this.name = name;
推荐阅读
- 江门联通dns服务器,江门联通DNS
- ios手机管家意义,ios手机管家在哪
- 网站制作教程,网站制作教程网站
- redismac破解版,redis客户端mac
- vb.net图表控件 vb控件图标
- redis关系图,redis存储关系型数据
- 做新媒体平台如何自我定位,如何进行新媒体用户定位
- css样式的选中文本框,css文字不能被选中
- vb.net结构数组 vbnet 数组