Professional Documents
Culture Documents
Color;
import java.awt.Graphics;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
public Elevator(int xAxis, int yAxis, int width, int height, int floor)
{
this.xAxis = xAxis;
this.yAxis = yAxis;
this.width = width;
this.height = height;
this.doorWidth = width / 2;
this.floor = floor;
this.isOpen = false;
this.isClose = true;
this.mode = Mode.WAIT;
this.direction = Mode.UP;
this.passengers = Collections.synchronizedList(new ArrayList());
test1 = true;
test2 = false;
test3 = false;
test4 = false;
test5 = false;
test6 = false;
test7 = false;
}
public void draw(Graphics g)
{
for (Passenger passenger : passengers)
{
passenger.draw(g);
}
--yAxis;
if (yAxis % 100 == 0)
{
++floor;
if (floor == 4)
{
direction = Mode.DOWN;
}
}
break;
case DOWN:
++yAxis;
if (yAxis % 100 == 0)
{
--floor;
if (floor == 0)
{
direction = Mode.UP;
}
}
break;
case OPEN:
if (doorWidth > 0)
{
--doorWidth;
}
else if (doorWidth == 0)
{
isOpen = true;
isClose = false;
}
break;
case CLOSE:
break;
default:
break;
}
}
while (iterator.hasNext())
{
Passenger temp = (Passenger) iterator.next();
if (temp.getDestinationFloor() == floor)
{
passengers.add(temp);
iterator.remove();
}
}
}