légères modif
This commit is contained in:
parent
ca166b8853
commit
733fd2a75e
@ -39,8 +39,9 @@ public class BasicInstructionQueue implements InstructionQueue {
|
|||||||
* direction the call is directed to.
|
* direction the call is directed to.
|
||||||
*/
|
*/
|
||||||
case CALLFROMFLOOR:
|
case CALLFROMFLOOR:
|
||||||
|
if (currentFloor == event.getIncomingCallFloor())
|
||||||
|
break;
|
||||||
switch (event.getRequestedDirection()) {
|
switch (event.getRequestedDirection()) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Adds the instruction to the upQueue then sorts it.
|
* Adds the instruction to the upQueue then sorts it.
|
||||||
*/
|
*/
|
||||||
@ -89,7 +90,7 @@ public class BasicInstructionQueue implements InstructionQueue {
|
|||||||
emergencyState = false;
|
emergencyState = false;
|
||||||
break;
|
break;
|
||||||
/*
|
/*
|
||||||
* Refreshes the local values of current floor and current direction with the
|
* Refreshes the local values of current floor and current rrentFloodirection with the
|
||||||
* ones given by the event. These values will
|
* ones given by the event. These values will
|
||||||
*/
|
*/
|
||||||
case REACHEDFLOORSIGNAL:
|
case REACHEDFLOORSIGNAL:
|
||||||
@ -112,7 +113,7 @@ public class BasicInstructionQueue implements InstructionQueue {
|
|||||||
public int getNextInstruction() {
|
public int getNextInstruction() {
|
||||||
int nextFloor = -1;
|
int nextFloor = -1;
|
||||||
|
|
||||||
//System.out.println("" + upQueue + downQueue);
|
System.out.println("we go " + currentDirection + " current floor: " + currentFloor + " queues: " + upQueue + downQueue);
|
||||||
|
|
||||||
switch (currentDirection) {
|
switch (currentDirection) {
|
||||||
// get the first element of upQueue that is ABOVE the elevator's current floor
|
// get the first element of upQueue that is ABOVE the elevator's current floor
|
||||||
@ -127,6 +128,9 @@ public class BasicInstructionQueue implements InstructionQueue {
|
|||||||
if (nextFloor < 0 && downQueue.size() > 0) {
|
if (nextFloor < 0 && downQueue.size() > 0) {
|
||||||
nextFloor = downQueue.get(0);
|
nextFloor = downQueue.get(0);
|
||||||
}
|
}
|
||||||
|
if (nextFloor < 0 && upQueue.size() > 0) {
|
||||||
|
nextFloor = upQueue.get(0);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// get the first element of downQueue that is UNDER the elevator's current floor
|
// get the first element of downQueue that is UNDER the elevator's current floor
|
||||||
@ -141,6 +145,9 @@ public class BasicInstructionQueue implements InstructionQueue {
|
|||||||
if (nextFloor < 0 && upQueue.size() > 0) {
|
if (nextFloor < 0 && upQueue.size() > 0) {
|
||||||
nextFloor = upQueue.get(0);
|
nextFloor = upQueue.get(0);
|
||||||
}
|
}
|
||||||
|
if (nextFloor < 0 && downQueue.size() > 0) {
|
||||||
|
nextFloor = downQueue.get(0);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -173,7 +180,8 @@ public class BasicInstructionQueue implements InstructionQueue {
|
|||||||
private void removeInstruction(int floor) {
|
private void removeInstruction(int floor) {
|
||||||
switch (currentDirection) {
|
switch (currentDirection) {
|
||||||
|
|
||||||
/*
|
/* current floor: 0 queues: [0, 1, 2, 3][4, 3, 2, 1]
|
||||||
|
Next instruction: 0
|
||||||
* Elevator is headed upwards.
|
* Elevator is headed upwards.
|
||||||
*/
|
*/
|
||||||
case UP:
|
case UP:
|
||||||
|
@ -8,7 +8,7 @@ import commandSystem.ElevatorListener;
|
|||||||
|
|
||||||
|
|
||||||
public class Elevator {
|
public class Elevator {
|
||||||
static final int PRECISION = 10;
|
static final int PRECISION = 100;
|
||||||
private double floorHeight;
|
private double floorHeight;
|
||||||
private double step;
|
private double step;
|
||||||
private double height;
|
private double height;
|
||||||
|
Reference in New Issue
Block a user