package edu.nyu.cs9053.concurrency.monitor;

/**
 * User: blangel
 * Date: 11/9/14
 * Time: 3:54 PM
 */
public class UnprotectedElevator implements Elevator {

    private int index;

    private final Object[] passengers;

    public UnprotectedElevator(int size) {
        this.passengers = new Object[size];
        this.index = 0;
    }

    public void add(Object passenger) {
        System.out.printf("Added passenger%n");
        passengers[index++] = passenger;
    }

    public Object remove() {
        Object passenger = passengers[index];
        System.out.printf("Removed passenger%n");
        passengers[index--] = null;
        return passenger;
    }

}
