From d85a80208c7107d12fa4912e8d7957f5e4e24f3b Mon Sep 17 00:00:00 2001 From: Fuyuxinge <1876397977@qq.com> Date: Sat, 21 Mar 2026 20:25:18 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=8C=E6=88=90w3=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=A4=B9Employee=E7=B1=BB=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- w3/Employee.java | 71 ++++++++++++++++++++++++++++++++++++++++++++++++ w3/test.java | 10 +++++++ 2 files changed, 81 insertions(+) create mode 100644 w3/Employee.java create mode 100644 w3/test.java diff --git a/w3/Employee.java b/w3/Employee.java new file mode 100644 index 0000000..580a0fe --- /dev/null +++ b/w3/Employee.java @@ -0,0 +1,71 @@ +public class Employee{ + private static String companyName; + private String id; + private String name; + private String department; + private double salary; + + public Employee(String id,String name,String department,double salary){ + this.id=id; + this.name=name; + this.department=department; + this.salary=salary; + if(companyName == null){ + companyName = "公司名"; + } + } + + public static String getCompanyName(){ + return companyName; + } + public static void setCompanyName(String companyName){ + Employee.companyName = companyName; + } + + 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 getDepartment() { + return department; + } + + public void setDepartment(String department) { + this.department = department; + } + + public double getSalary() { + return salary; + } + + public void setSalary(double salary){ + if(salary >= 2000){ + this.salary=salary; + } else { + System.out.println("低于最低工资标准"); + this.salary = 2000; + } + } + public void raiseSalary(double percent) { + double newSalary = this.salary * (1 + percent / 100); + setSalary(newSalary); + } + public void printInfo() { + System.out.println("公司名称:" + companyName); + System.out.println("工号:" + id); + System.out.println("姓名:" + name); + System.out.println("部门:" + department); + System.out.println("工资:" + salary); + System.out.println("------------------------"); + } +} \ No newline at end of file diff --git a/w3/test.java b/w3/test.java new file mode 100644 index 0000000..0feeb9a --- /dev/null +++ b/w3/test.java @@ -0,0 +1,10 @@ +public class test { + public static void main(String[] args) { + Employee emp1 = new Employee("E001", "张三", "技术部", 8000); + Employee emp2 = new Employee("E002", "李四", "市场部", 6000); + + System.out.println("员工信息"); + emp1.printInfo(); + emp2.printInfo(); + } +}