|
@ -1,6 +1,14 @@ |
|
|
package de.hsfulda.onses.models; |
|
|
package de.hsfulda.onses.models; |
|
|
|
|
|
|
|
|
|
|
|
import java.beans.PropertyChangeSupport; |
|
|
|
|
|
|
|
|
public class Card { |
|
|
public class Card { |
|
|
|
|
|
|
|
|
|
|
|
public final static String PROPERTY_COLOR = "color"; |
|
|
|
|
|
public final static String PROPERTY_VALUE = "value"; |
|
|
|
|
|
|
|
|
|
|
|
protected PropertyChangeSupport listeners; |
|
|
|
|
|
|
|
|
private Color color; |
|
|
private Color color; |
|
|
private Value value; |
|
|
private Value value; |
|
|
|
|
|
|
|
@ -12,12 +20,16 @@ public class Card { |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
public Card setColor(Color color) { |
|
|
public Card setColor(Color color) { |
|
|
|
|
|
final Card.Color oldColor = this.color; |
|
|
this.color = color; |
|
|
this.color = color; |
|
|
|
|
|
this.firePropertyChange(PROPERTY_COLOR, oldColor, color); |
|
|
return this; |
|
|
return this; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public Card setValue(Value value) { |
|
|
public Card setValue(Value value) { |
|
|
|
|
|
final Card.Value oldValue = this.value; |
|
|
this.value = value; |
|
|
this.value = value; |
|
|
|
|
|
this.firePropertyChange(PROPERTY_VALUE, oldValue, value); |
|
|
return this; |
|
|
return this; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -28,4 +40,19 @@ public class Card { |
|
|
public Value getValue() { |
|
|
public Value getValue() { |
|
|
return this.value; |
|
|
return this.value; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public PropertyChangeSupport listeners() { |
|
|
|
|
|
if(this.listeners == null) { |
|
|
|
|
|
this.listeners = new PropertyChangeSupport(this); |
|
|
|
|
|
} |
|
|
|
|
|
return this.listeners; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public boolean firePropertyChange(String propertyName, Object oldValue, Object newValue) { |
|
|
|
|
|
if (this.listeners != null) { |
|
|
|
|
|
this.listeners.firePropertyChange(propertyName, oldValue, newValue); |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
} |
|
|
} |