package pom; import java.util.ArrayList; import java.util.Scanner; class FactoryAccessControlSystem { public static void main(String[] args) { Scanner input = new Scanner(System.in); ArrayList<Employee> employees = new ArrayList<>(); // 将员工对象添加到员工列表 employees.add(new Employee("aa", "b", 1, 10)); employees.add(new Employee("bb", "d", 2, 5)); System.out.print("Enter employee first name: "); String firstName = input.nextLine(); System.out.print("Enter employee last name: "); String lastName = input.nextLine(); System.out.print("Enter floor number: "); int floorNumber = input.nextInt(); // 检查员工是否可以进入楼层 boolean accessGranted = false; for (Employee employee : employees) { if (employee.getFirstName().equals(firstName) && employee.getLastName().equals(lastName)) { if (floorNumber >= employee.getMinFloor() && floorNumber <= employee.getMaxFloor()) { accessGranted = true; } } } if (accessGranted) { System.out.println("Access granted."); } else { System.out.println("Access denied."); } } } class Employee { private final String firstName; private final String lastName; private final int minFloor; private final int maxFloor; public Employee(String firstName, String lastName, int minFloor, int maxFloor) { this.firstName = firstName; this.lastName = lastName; this.minFloor = minFloor; this.maxFloor = maxFloor; } public String getFirstName() { return firstName; } public String getLastName() { return lastName; } public int getMinFloor() { return minFloor; } public int getMaxFloor() { return maxFloor; } }
【无标题】门禁员工管理系统(源码)
最新推荐文章于 2024-04-20 02:02:07 发布