Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>What a weird programming ...</p> <p>However, the problem seems to be sitting here:</p> <p>1) In class <code>Game</code> you have a static field of type <code>HashMap&lt;Block, Coordinates&gt;</code> called <em>blocks</em>. You are inserting instances of class <code>Block</code> for the keys into that map. Corresponding line is:</p> <pre><code>blocks.put(new Block(new BlockRectangle(rectID)), new Coordinates(rectx, recty)); </code></pre> <p>2) While also creating an instace of type <code>BlockRectangle</code> in the same line, the constructor puts the object in construction as a key into the the static field of type <code>HashMap&lt;Integer, BlockRectangle&gt;</code> called <em>rects</em>. Corresponding line is:</p> <pre><code>rects.put(id, this); </code></pre> <p>3) Then you are trying to get a Block by calling</p> <pre><code>blocks.get(BlockRectangle.getByID(rectID)) </code></pre> <p>The inner expression <code>BlockRectangle.getByID(rectID)</code> will return a <code>BlockRectangle</code> instance that is looked up in the map <em>rects</em>. With this instance now a lookup is done in the map <em>blocks</em>, but this only stores <code>Block</code>s as keys, not <code>BlockRectangle</code>s (see point 1).</p> <p>Without any <code>equals</code> (and <code>hashCode</code>) method in <code>Block</code> and <code>BlockRectangle</code>, you are not getting any further. But implementing those methods in any of these classes make it worse, as it will not be a good idea to compare blocks with block rectangles.</p> <p>You should do a complete redesign of your software.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload