I want to create a list of classes with different attributes but i'm facing a problem: when I add a new one, all the others are modify.(the code is really big so i'm posting just a small sample)
public abstract class A{
public static Point Position;
public static int LifePoints;
public static int range;
public static int atackValue;
public static double movementSpeed;
public double getMovementSpeed() {
return movementSpeed;
}
public static void setMovementSpeed(double movement) {//this n funciona
movementSpeed = movement;
}
(...)to make the topic shorter i only show the movement part but class A contains all getters and setters for all movement,position,range,life points and attack value
}
public class B extends A{
public static Point Position;
public static int LifePoints=10000;
public static int range=50;
public static int atackValue=100;
public static double movementSpeed=2;
public A(Point startPoint){
setMovementSpeed(movementSpeed);
setAtackValue(atackValue);
setRange(range);
setLifePoints(LifePoints);
setPosition(startPoint);
}
public class createB(){
(...)
public void create(){
private List<B> list = new ArrayList<B>();
B b = new B(startpoint);
list.add(b);
}
(...)
for(int x=0;x!=list.length();x++){
move(list.get(x));
system.out.println(list.get(x).getMovementSpeed());
}
The println returns the correct value (2.0) for all b's created but everytime I create a new b all the other b's stop moving and the new b moves faster than the previous one. The move function it's made by my teacher and it's confirmed to be working correctly. I suspect the position isn't working correctly and instead of moving the pictures 2 pixels it moves only one X times.