title: Make an object in two child views equal
body: <p>I have two view classes, <code>HitOrMiss</code> and <code>PlaceShips</code>, that extend a class, <code>BuildGame</code>. BuildGame has an object, <code>mGame</code>. At runtime 2 instances of mGame are created, one for each child class. mGame contains a list of listeners among other things, however HitOrMiss and PlaceShips only add their listeners to their own instances of mGame. As a result the individual views only update when you tap on that specific one.</p>
  
  <p>Essentially I am trying to set the mGame of one of the views to the mGame of the other, so that will just update the reference to the same object, but I can't figure out how! Setting mGame to <code>static</code> does work, however, my lecturer for this unit has said there is another way without using static and i'd lose marks, which is fair enough.</p>
  
  <p>BuildGame:</p>
  
  <pre><code>public class BuildGame extends View {
  protected final BaseSubClass mGame = new BaseSubClass(10, 10, BattleshipGameBase.ShipData.CREATOR.newArray(5));
  private Paint mGridPaint, mPlayer1Paint, mPlayer2Paint, mBGPaint, mHitPaint, mMissPaint;
  protected float diameterX, diameterY, chosenDiameter, separatorSize, canvasWidth, canvasHeight;
  protected int tokenAtPos;
  
  public BuildGame(Context context, AttributeSet attrs) {
      super(context, attrs);
      initialise();
  }
  </code></pre>
  
  <p>PlacedShips and HitOrMiss are essentially the same snippet apart from the name:</p>
  
  <pre><code>public class PlaceShips extends BuildGame {
  
  private GestureDetector mGestureDetector;
  private int placedShipNo = 0;
  
  public PlaceShips(Context context, AttributeSet attrs) {
      super(context, attrs);
      mGestureDetector = new GestureDetector(context, new MyGestureListener());
  
      //GameplayListenerStuff
      BattleshipGameBase.BattleshipGameListener mGameplayListenerPS = new BattleshipGameBase.BattleshipGameListener() {
          @Override
          public void onGameChanged(BattleshipGameBase game, int column, int row) {
              System.out.println("onGameChangedPS");
              invalidate();
          }
      };
      mGame.addOnGameChangeListener(mGameplayListenerPS);
  }
  </code></pre>