Java代码创建营业员类 java程序怎么创建

用Java语言定义一个员工类Employeepublic class Employee {
private String id; // 员工ID号
private String name; // 姓名
private int age; // 年龄
private boolean sex; // 性别(其中:true表示男,false表示女)
private String phone; // 联系电话
private float salary; // 薪水
Employee(String sId, String sName, int sAge, boolean sSex, String sPhone,
float sSalary) {
this.id = sId;
this.name = sName;
this.age = sAge;
this.sex = sSex;
this.phone = sPhone;
this.salary = sSalary;
}
public String toString() {
return "员工ID号:" + this.id + "\n员工姓名:" + this.name + "\n员工年龄:"
+ this.age + "\n员工性别:" + (this.sex == true ? "男" : "女")
+ "\n联系电话:" + this.phone + "\n薪水:" + this.salary;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public float getSalary() {
return salary;
}
public void setSalary(float salary) {
this.salary = salary;
}
public boolean isSex() {
return sex;
}
public void setSex(boolean sex) {
this.sex = sex;
}
}
用java编写员工类Employeepublic class Employee {
private int id;
private byte sex;
private String name;
private String duty;
private float salary;
private int holidays;
public Employee(int id,byte sex,String name,String duty, float salary,int holidays){
this.id = id;
this.sex = sex;
this.name = name;
this.duty = duty;
this.salary = salary;
this.holidays = holidays;
}
public String getDuty() {
return duty;
}
public void setDuty(String duty) {
this.duty = duty;
}
public int getHolidays() {
return holidays;
}
public void setHolidays(int holidays) {
this.holidays = holidays;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public float getSalary() {
return salary;
}
public void setSalary(float salary) {
this.salary = salary;
}
public byte getSex() {
return sex;
}
public void setSex(byte sex) {
this.sex = sex;
}
/**
* display(),无返回值,该方法能打印员工的姓名、性别以及职务
* @param employee
*/
public void display(Employee employee){
System.out.println("员工姓名为: " + employee.getName());
if(employee.getSex()==1){
System.out.println("员工性别为: 男 ");
}else if(employee.getSex()==2){
System.out.println("员工性别为:女 ");
}
System.out.println("员工职务为: " + employee.getDuty());
}
/**
* getDecMoney(int day) 返回值是int型 。
* 如果请假天数=3,则扣款为30×请假天数;
* 如果请假天数超过3天,则扣款为50×请假天数 。
* @param day
* @return
*/
public intgetDecMoney(int day){
int deduction = 0; //扣除的工资
if(day = 3){
deduction = 30*day;
}else if(day3){
deduction = 50*day;
}
return deduction;
}
public static void main(String[] args){

推荐阅读