I am trying to create a check in/check out employee management systems in java.
I have an employee class with get/set method with follow attributes
private int employeeID;
private String empName;
private double amountOfItemSold;
private double empWage;
private double timeWorked;
Can you guys help me write it to keep track of employees. I would like to create objects and stored them in an arraylist or hashmap..... thank you.
Here's the code.
import java.util.ArrayList;
public class CheckIn {
public static void main(String[] args){
ArrayList<Employee> employees = new ArrayList<>();
Employee e1 = new Employee(1,"John",12.2,1234.45,24);
Employee e2 = new Employee(2,"Mark",13.2,1235.45,25);
Employee e3 = new Employee(3,"Jenn",14.2,1236.45,26);
Employee e4 = new Employee(4,"Parker",15.2,1237.45,27);
employees.add(e1);
employees.add(e2);
employees.add(e3);
employees.add(e4);
Employee e = null;
for(int i=0; i<employees.size(); i++){
e=employees.get(i);
System.out.println("Employee Id: "+e.getEmpId());
System.out.println("Employee Name: "+e.getName());
System.out.println("Amount of item sold: "+e.getAmountOfItemSold());
System.out.println("Employee wage: "+e.getEmpWage());
System.out.println("Time worked: "+e.getTimeWorked()+"\n\n");
}
}
}
class Employee{
private int empId;
private String name;
private double amountOfItemSold;
private double empWage;
private double timeWorked;
public Employee(int empId, String name, double amountOfItemSold, double empWage, double timeWorked) {
this.empId = empId;
this.name = name;
this.amountOfItemSold = amountOfItemSold;
this.empWage = empWage;
this.timeWorked = timeWorked;
}
public int getEmpId() {
return empId;
}
public void setEmpId(int empId) {
this.empId = empId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getAmountOfItemSold() {
return amountOfItemSold;
}
public void setAmountOfItemSold(double amountOfItemSold) {
this.amountOfItemSold = amountOfItemSold;
}
public double getEmpWage() {
return empWage;
}
public void setEmpWage(double empWage) {
this.empWage = empWage;
}
public double getTimeWorked() {
return timeWorked;
}
public void setTimeWorked(double timeWorked) {
this.timeWorked = timeWorked;
}
}
Output:
======

Please comment if you need any help.
I am trying to create a check in/check out employee management systems in java. I have...