版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。
以下笔记摘自《java核心技术卷1》
以下给出了一个薪金管理系统的一部分代码
package Employee; import java.time.LocalDate; public class Employee { private String name; private double salary; private LocalDate hireDay; public Employee(String name, double salary, int year,int month,int day) { this.name = name; this.salary = salary; this.hireDay = LocalDate.of(year,month,day); } 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; } public LocalDate getHireDay() { return hireDay; } public void setHireDay(LocalDate hireDay) { this.hireDay = hireDay; } public void raiseSalary(double byPercent) { double raise=salary*byPercent/100; salary+=raise; } } package Employee; public class EmployeeTest { public static void main(String[] args) { Employee[] staff = new Employee[3]; staff[0] = new Employee("Carl",75000,1987,12,15); sta