Changes

Jump to: navigation, search

Teams Winter 2011/team2/lab3

1,698 bytes added, 22:37, 22 March 2011
no edit summary
<source lang=java>
package ecl.team2.lab3.weathermodel;
 
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.util.Random;
public class Weather {
private float windspeedInKM;
private char windDirection;
private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
public Weather()
{
}
public Weather(String cit)
{
city=cit;
Random randomGenerator = new Random();
tempInCelcius = randomGenerator.nextFloat()+35;
rainInMM = randomGenerator.nextFloat()+10;
snowInMM = randomGenerator.nextFloat()+10;
windspeedInKM = randomGenerator.nextFloat()+50;
int r = randomGenerator.nextInt(4);
switch(r){
case 0:
windDirection = 'E';
break;
case 1:
windDirection = 'W';
break;
case 2:
windDirection = 'N';
break;
case 3:
windDirection = 'S';
break;
}
}
public Weather(String pcity, float ptemp, float prain, float psnow, float pwspeed, char pwdirection){
public void setWindDirection(char windDirection) {
propertyChangeSupport.firePropertyChange("", this.windDirection, this.windDirection = windDirection);
}
public void setWindspeedInKM(float windspeedInKM) {
propertyChangeSupport.firePropertyChange("", this.windspeedInKM, this.windspeedInKM = windspeedInKM);
}
public void setSnowInMM(float snowInMM) {
propertyChangeSupport.firePropertyChange("", this.snowInMM, this.snowInMM = snowInMM);
}
public void setRainInMM(float rainInMM) {
propertyChangeSupport.firePropertyChange("", this.rainInMM, this.rainInMM = rainInMM);
}
public void setTempInCelcius(float tempInCelcius) {
propertyChangeSupport.firePropertyChange("", this.tempInCelcius, this.tempInCelcius = tempInCelcius);
}
public void setCity(String city) {
propertyChangeSupport.firePropertyChange("", this.city, this.city = city);
}
public String getCity() {
return city;
}
public void addPropertyChangeListener(String name, PropertyChangeListener listener)
{
propertyChangeSupport.addPropertyChangeListener(name,listener);
}
public void removePropertyChangeListener(PropertyChangeListener listener)
{
propertyChangeSupport.addPropertyChangeListener(listener);
}
1
edit

Navigation menu