ajout de requêtes

This commit is contained in:
MathieuPietri 2019-10-14 13:59:12 +02:00
parent 483a5a8189
commit 9a9c128f31
8 changed files with 42 additions and 13 deletions

View File

@ -1 +0,0 @@
,p16003795,L-662722FORM-16.salsa.univ-amu.fr,14.10.2019 13:17,file:///amuhome/p16003795/.config/libreoffice/4;

View File

@ -3,8 +3,7 @@ package Requests;
public class CallFromElevatorRequest extends Request { public class CallFromElevatorRequest extends Request {
public CallFromElevatorRequest(int wantedFloor) { public CallFromElevatorRequest(int wantedFloor) {
super(); super(RequestType.CALLFROMELEVATOR);
this.wantedFloor = wantedFloor; this.wantedFloor = wantedFloor;
this.type = RequestType.CALLFROMELEVATOR;
} }
} }

View File

@ -6,10 +6,9 @@ public class CallFromFloorRequest extends Request {
public CallFromFloorRequest(int sourceFloor, Direction direction) { public CallFromFloorRequest(int sourceFloor, Direction direction) {
super(); super(RequestType.CALLFROMFLOOR);
this.sourceFloor = sourceFloor; this.sourceFloor = sourceFloor;
this.direction = direction; this.direction = direction;
this.type = RequestType.CALLFROMFLOOR;
} }
} }

View File

@ -0,0 +1,9 @@
package Requests;
public class CancelEmergencyStopRequest extends Request{
public CancelEmergencyStopRequest() {
super(RequestType.CANCELEMERGENCYSTOP);
}
}

View File

@ -3,7 +3,6 @@ package Requests;
public class EmergencyStopRequest extends Request { public class EmergencyStopRequest extends Request {
public EmergencyStopRequest() { public EmergencyStopRequest() {
super(); super(RequestType.EMERGENCYSTOP);
this.type = RequestType.EMERGENCYSTOP;
} }
} }

View File

@ -0,0 +1,10 @@
package Requests;
public class ReachedFloorSignal extends Request{
public ReachedFloorSignal(int reachedFLoor) {
super(RequestType.REACHEDFLOORSIGNAL);
this.reachedFloor = reachedFLoor;
}
}

View File

@ -8,8 +8,11 @@ public abstract class Request {
protected int wantedFloor; protected int wantedFloor;
protected int sourceFloor; protected int sourceFloor;
protected Direction direction; protected Direction direction;
protected int reachedFloor;
public Request() { public Request(RequestType type) {
this.type = type;
this.reachedFloor = -1;
this.wantedFloor = -1; this.wantedFloor = -1;
this.sourceFloor = -1; this.sourceFloor = -1;
this.direction = Direction.NONE; this.direction = Direction.NONE;
@ -17,7 +20,7 @@ public abstract class Request {
/** /**
* *
* @return the direction of the request, unconcerned extending classes return NONE * @return the direction of the request, unconcerned extending classes return NONE.
*/ */
public Direction getDirection() { public Direction getDirection() {
return direction; return direction;
@ -25,7 +28,7 @@ public abstract class Request {
/** /**
* *
* @return the wished floor, unconcerned extending classes return -1 * @return the wished floor, unconcerned extending classes return -1.
*/ */
public int getWantedFloor() { public int getWantedFloor() {
return wantedFloor; return wantedFloor;
@ -33,14 +36,25 @@ public abstract class Request {
/** /**
* *
* @return the floor it was called from, unconcerned extending classes return -1 * @return the floor it was called from, unconcerned extending classes return -1.
*/ */
public int getIncomingCallFloor() { public int getIncomingCallFloor() {
return sourceFloor; return sourceFloor;
} }
/**
*
* @return the RequestType of the request.
*/
public RequestType getType() { public RequestType getType() {
return type; return type;
} }
/**
*
* @return the floor the elevator just reached, unconcerned extending classes return -1.
*/
public int getReachedFloor() {
return reachedFloor;
}
} }

View File

@ -1,5 +1,5 @@
package Requests; package Requests;
public enum RequestType { public enum RequestType {
CALLFROMFLOOR, CALLFROMELEVATOR, EMERGENCYSTOP, CANCELEMERGENCYSTOP CALLFROMFLOOR, CALLFROMELEVATOR, EMERGENCYSTOP, CANCELEMERGENCYSTOP, REACHEDFLOORSIGNAL
} }