Created
February 28, 2016 08:29
-
-
Save addicted2sounds/6ffcbad79af70f02a836 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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