Commit f315e3c5 authored by Julian Zobel's avatar Julian Zobel
Browse files

Made AttractionPointImpl an extension to BasicAttractionPoint, since both did...

Made AttractionPointImpl an extension to BasicAttractionPoint, since both did iomplement exactly the same base functions.
parent 454ee95c
...@@ -33,56 +33,25 @@ import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Attraction ...@@ -33,56 +33,25 @@ import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Attraction
* We hold a static list of attraction points to ensure that there exists only * We hold a static list of attraction points to ensure that there exists only
* one instance of each name at a time. * one instance of each name at a time.
* *
* @author Christoph Muenker, Bjoern Richerzhagen * @author Christoph Muenker, Bjoern Richerzhagen, Julian Zobel
* @version 1.0, 02.07.2013 * @version 1.0, 02.07.2013
* @version 1.1, 26.10.2018 - since the class was very similar to {@link BasicAttractionPoint}, made this class an extension
*/ */
public class AttractionPointImpl extends PositionVector public class AttractionPointImpl extends BasicAttractionPoint {
implements AttractionPoint {
protected static Random rnd = Randoms.getRandom(AttractionPoint.class); protected static Random rnd = Randoms.getRandom(AttractionPoint.class);
protected static Map<String, AttractionPointImpl> instances = new LinkedHashMap<>();
private static Map<String, AttractionPointImpl> instances = new LinkedHashMap<>();
private String name;
private double weight = 0;
private double radius = 0;
public AttractionPointImpl(String name, PositionVector posVec) { public AttractionPointImpl(String name, PositionVector posVec) {
super(posVec); super(name, posVec);
this.name = name;
if (instances.containsKey(name)) { if (instances.containsKey(name)) {
throw new AssertionError("Name "+name+" already in use for an attraction point."); throw new AssertionError("Name "+name+" already in use for an attraction point.");
} }
instances.put(name, this); instances.put(name, this);
} }
@Override
public String getName() {
return name;
}
@Override
public double getWeight() {
return weight;
}
@Override
public double getRadius() {
return radius;
}
@Override
public void setWeight(double weight) {
this.weight = weight;
}
@Override
public void setRadius(double radius) {
this.radius = radius;
}
@Override @Override
public AttractionPoint clone(String newName) { public AttractionPoint clone(String newName) {
return new AttractionPointImpl(name, this); return new AttractionPointImpl(name, this);
......
...@@ -9,12 +9,11 @@ import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Attraction ...@@ -9,12 +9,11 @@ import de.tudarmstadt.maki.simonstrator.api.component.sensor.location.Attraction
*/ */
public class BasicAttractionPoint extends PositionVector implements AttractionPoint public class BasicAttractionPoint extends PositionVector implements AttractionPoint
{ {
private String name; protected String name;
private double weight = 0; protected double weight = 0;
private double radius = 0; protected double radius = 0;
public BasicAttractionPoint(String name, PositionVector pos) public BasicAttractionPoint(String name, PositionVector pos) {
{
super(pos); super(pos);
this.name = name; this.name = name;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment