说我有一个A类如下
    public class A {
      protected static float[] floatArray = null;
      protected static Map<Integer, float[]>  history = new HashMap<Integer,float[]>();
      protected static Integer historyCount = 0;
      public void runEverySecond(Populator objPopulator) {
         floatArray = objPopulator.getValues();
         history.put(historyCount, floatArray);
         historyCount++;
      }  
    }
B类看起来如下
    public class B {
      private A objA;
      protected final static Populator objPopulator = new Populator();
      public void run(Integer numOfTime) {
        for(int i = 0; i < numOfTime; i++)
           objA.runEverySecond(objPopulator);
      }
    }
和类 Populator 如下所示
    public class Populator {
      protected float[] randomValues = new float[2];
      public float[] getValues() {
        randomValues[0] = //some new random float value generated for every call
        randomValues[1] = //some new random float value generated for every call
        return randomValues;
      }
    }
和包含主要外观的类如下
    public class MainClass {
      public static void main() {
        final B objB = new B();
        objB.run(10);
      }
    }
这是我面临的问题,地图历史记录包含地图中每个条目的相同值。我希望地图历史记录存储 objPopulator.getValues() 方法生成的所有值。我该怎么做?
一些帮助将非常明显。提前致谢 :)
由 A 类表示的实际代码(已删除无关代码)
public class MySuperAgent implements Agent {
protected static float[] marioFloatPos = null;
protected static Map<Integer, float[]> levelRecord = new HashMap<Integer, float[]>();
protected static Integer mapCount = 0;
/*  protected static int testCount = 0;
protected static float[] testx = new float[2];
protected static float[] testy = new float[2];*/
@Override
public void integrateObservation(Environment environment) {
    marioFloatPos = environment.getMarioFloatPos();
    levelRecord.put(mapCount, marioFloatPos);
    mapCount++;
   /*if(testCount < 2){
        testx[testCount] = marioFloatPos[0];
        testy[testCount] = marioFloatPos[1];
        testCount++;
    } else {
        testCount = 0;
    }*/
  }
}
如果我使用注释块中的代码,则从类似于 B 类的类调用 C 类表示环境对象集成观察方法,那么我只能记录马里奥的 x 和 y 的 2 个过去值。我需要一种方法来存储马里奥的 x 和 y 的所有值:)