Skip to content

Commit

Permalink
TirePressureMonitoringSystem/JavaScript: deleted unnecessary code and…
Browse files Browse the repository at this point in the history
… synchronised the proposed solution with changes in the original exercise.
  • Loading branch information
Luca Minudel committed Sep 12, 2013
1 parent 83486de commit 12aa637
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ Alarm = function(sensor) {
this._highPressureTreshold = 21;
this._sensor = sensor;
this._alarmOn = false;
this._alarmCount = 0;
};

Alarm.Create = function() {
Expand All @@ -21,7 +20,6 @@ Alarm.prototype = {
if (psiPressureValue < this._lowPressureTreshold || this._highPressureTreshold < psiPressureValue)
{
this._alarmOn = true;
this._alarmCount += 1;
}
},

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@

Sensor = function() {
//
// The reading of the pressure value from the sensor is simulated in this implementation.
// Because the focus of the exercise is on the other class.
//

Sensor.Offset = function() { return 16; };
Sensor.SamplePressure = function() {
Sensor.ReadPressureSample = function() {
// placeholder implementation that simulate a real sensor in a real tire

var pressureTelemetryValue = Math.floor(6 * Math.random() * Math.random());

return pressureTelemetryValue;
};
};

Sensor.prototype = {

popNextPressurePsiValue: function () {
var pressureTelemetryValue = Sensor.SamplePressure();
var pressureTelemetryValue = Sensor.ReadPressureSample();

return Sensor.Offset() + pressureTelemetryValue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ Alarm = function() {
this._highPressureTreshold = 21;
this._sensor = new Sensor();
this._alarmOn = false;
this._alarmCount = 0;
};

Alarm.prototype = {
Expand All @@ -17,7 +16,6 @@ Alarm.prototype = {
if (psiPressureValue < this._lowPressureTreshold || this._highPressureTreshold < psiPressureValue)
{
this._alarmOn = true;
this._alarmCount += 1;
}
},

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@

Sensor = function() {
//
// The reading of the pressure value from the sensor is simulated in this implementation.
// Because the focus of the exercise is on the other class.
//

Sensor.Offset = function() { return 16; };
Sensor.SamplePressure = function() {
Sensor.ReadPressureSample = function() {
// placeholder implementation that simulate a real sensor in a real tire

var pressureTelemetryValue = Math.floor(6 * Math.random() * Math.random());
return pressureTelemetryValue;

return pressureTelemetryValue;
};
};

Sensor.prototype = {

popNextPressurePsiValue: function () {
var pressureTelemetryValue = Sensor.SamplePressure();
var pressureTelemetryValue = Sensor.ReadPressureSample();

return Sensor.Offset() + pressureTelemetryValue;
}
Expand Down

0 comments on commit 12aa637

Please sign in to comment.