Skip to content

Instantly share code, notes, and snippets.

@addicted2sounds
Created February 28, 2016 08:29
Show Gist options
  • Save addicted2sounds/6ffcbad79af70f02a836 to your computer and use it in GitHub Desktop.
Save addicted2sounds/6ffcbad79af70f02a836 to your computer and use it in GitHub Desktop.
package com.company;
/**
* Created by addicted on 27.02.16.
*/
public class Weather {
private double windDirection;
private double windSpeed;
private double temperature;
private PrecipitationTypes precipitations;
public Weather(double windDirection, double windSpeed, double temperature, PrecipitationTypes precipitations) {
this.windDirection = windDirection;
this.windSpeed = windSpeed;
this.temperature = temperature;
this.precipitations = precipitations;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Weather weather = (Weather) o;
if (Double.compare(weather.windDirection, windDirection) != 0) return false;
if (Double.compare(weather.windSpeed, windSpeed) != 0) return false;
if (Double.compare(weather.temperature, temperature) != 0) return false;
if (weather.precipitations != precipitations) return false;
return precipitations == weather.precipitations;
}
@Override
public int hashCode() {
int result;
long temp;
temp = Double.doubleToLongBits(windDirection);
result = (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(windSpeed);
result = 31 * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(temperature);
result = 31 * result + (int) (temp ^ (temp >>> 32));
result = 31 * result + precipitations.hashCode();
return result;
}
@Override
public String toString() {
return "Weather{" +
"windDirection=" + windDirection +
", windSpeed=" + windSpeed +
", temperature=" + temperature +
", precipitations=" + precipitations +
'}';
}
public double getWindDirection() {
return windDirection;
}
public void setWindDirection(double windDirection) {
this.windDirection = windDirection;
}
public double getWindSpeed() {
return windSpeed;
}
public void setWindSpeed(double windSpeed) {
this.windSpeed = windSpeed;
}
public double getTemperature() {
return temperature;
}
public void setTemperature(double temperature) {
this.temperature = temperature;
}
public PrecipitationTypes getPrecipitations() {
return precipitations;
}
public void setPrecipitations(PrecipitationTypes precipitations) {
this.precipitations = precipitations;
}
enum PrecipitationTypes { RAIN, SNOW, SUNNY, CLOUDY }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment