【无标题】门禁员工管理系统(源码)

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;
    }

}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值