Generation

generate functionTue, 24 Jan 2023

constructor of the class will be all the data except the employee number, which will be a generated number (the first employee to be employee number 1, the second employee number 2 and so on). and so on)

public class Employee { private int employeeNumber; private String employeeName; private String employeeAddress; private int employeeAge; private double employeeSalary; // private static int numberOfEmployees = 1; public Employee() { this.employeeNumber = numberOfEmployees++; this.employeeName = ""; this.employeeAddress = ""; this.employeeAge = 0; this.employeeSalary = 0.0; } public Employee(String employeeName, String employeeAddress, int employeeAge, double employeeSalary) { this.employeeNumber = numberOfEmployees++; this.employeeName = employeeName; this.employeeAddress = employeeAddress; this.employeeAge = employeeAge; this.employeeSalary = employeeSalary; }

Questions about programming?Chat with your personal AI assistant