Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work3 #320

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
Emergency braking
mestergy committed Apr 2, 2023
commit 7d36cbf4780e024d9a2c390233c64e212e6e64e9
Original file line number Diff line number Diff line change
@@ -6,4 +6,6 @@ public interface TrainSensor {

void overrideSpeedLimit(int speedLimit);

void dangerDetection(boolean hazard);

}
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@ public class TrainSensorImpl implements TrainSensor {
private TrainController controller;
private TrainUser user;
private int speedLimit = 5;
private boolean danger = false;

public TrainSensorImpl(TrainController controller, TrainUser user) {
this.controller = controller;
@@ -26,4 +27,10 @@ public void overrideSpeedLimit(int speedLimit) {
controller.setSpeedLimit(speedLimit);
}

@Override
public void dangerDetection(boolean hazard) {
if (hazard == true)
danger = true;
}

}