Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. (function () {
  2. let closureId = 0;
  3. return class Record {
  4. constructor(temperature, humidity, pressure, windSpeed) {
  5. this.id = closureId++;
  6. this.temperature = temperature;
  7. this.humidity = humidity;
  8. this.pressure = pressure;
  9. this.windSpeed = windSpeed;
  10. }
  11.  
  12. get status() {
  13. if(this.temperature < 20
  14. && (this.pressure < 700 || this.pressure > 900)
  15. && this.windSpeed > 25){
  16. return 'Stormy';
  17. }
  18.  
  19. return 'Not stormy';
  20. }
  21.  
  22. toString() {
  23. let result = `Reading ID: ${this.id}
  24. Temperature: ${this.temperature}*C
  25. Relative Humidity: ${this.humidity}%
  26. Pressure: ${this.pressure}hpa
  27. Wind Speed: ${this.windSpeed}m/s
  28. Weather: ${this.status}`;
  29. return result;
  30. }
  31. }
  32. })()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement