Answer to Question #3076 in AJAX | JavaScript | HTML | PHP for David




 Hey I'm just wondering when I run my program it shows theres something wrong with one of my method &quot;turn&quot;:  

Method:  

 public void turn()  

 {  

 Move move = ui.nextMove();  

 if (move == Move.LEFT || move == Move.RIGHT)  

 {  

 player.move(move.dx);  

 if (player.isAlive() && exit.found(player) && itemsCollected())  

 exit.take();  

 }  

 else if (move == Move.DOWN)  

 {  

 for (int i=0;i&lt;items.length;i++)  

 player.pickup(items[i]);   

 }  

  

 for (int i=0;i&lt;enemies.length;i++)  

 enemies[i].attack(player);  

  

 }  

  

The results of the program comes out with:  

  

Your move (l/r/p): l  

 &gt;  

 &gt; java.lang.NullPointerException  

 &gt; at Game.turn(Game.java:123)  

 &gt; at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Metho  

 &gt; at   

  

PLEASE HELP ASAP =)
We need the whole code to answer to your question. [submit your assignment](https://www.assignmentexpert.com/submit) to our control panel and our experts will help you.
hey [@jsteb](/u/jsteb), i was struggling with this and i figured what is going on. the problem is with the action button. if you try with a regular button it will work. i think that should be clarified in the tutorial && is a short circuit operator in java, which means that once it evaluates the left expression as false - it no longer evaluates the right expression.   

in our case, in the equals method evaluates 

```

obj instanceof person 
```
 to **true**; 

```

this.age == ((person)obj).age 
```
 to **false**; the next expression, 
```

this.name.equals(((person)obj).name);
```
 is not evaluated at all, and the method returns **false**.   

changing the && operator to || or & would result in a java.lang.nullpointerexception it could be a random drop or a glitch. if you've got the item and nothing else is wrong with the game, enjoy! from the code, it might be that capture is called before turnon completes.

could you check that the “callback” passed to turnon is called before you call capture? kindly refer the following link for similar query
https://www meritnation
com/ask-answer/question/why-does-a-ball-rolling-on-the-ground-in-a-straight-come/science/8033135 can you try with other dropdowns? if its working , nothing wrong with your code and something to do with that specific drop down. that error happens when there's no handle to close. i see you call the 'open()' and you're not getting an object reference error before closehandle(). check your memory.pointerwrite() function to make sure it's not doing a closehandle() prematurely. it sounds like you're calling closehandle() twice. the code you posted above still has the original img tag with joy.jpg, so it doesn't show what you entered that did not work.
but taking a wild guess, i would point out that javascript is case-sensitive, and so is the challenge checker, so if you accidentally substituted lower case for upper case, or vice-versa, it would not work in the code or pass the challenge. You're adding the bullet as the child of the player, so naturally it's going to move with the player.


Instead, you should add your bullets to the world. This could be as simple as `get_parent().add_child(bullet)`, or you can use `get_node()` to use whichever node you want to hold the bullets. Are you trying to return [Target] as [Target?]. Since the content types of the array don't match (and can't match), you get a runtime exception. Changed return type to [Target], especially since you always return something anyway.



  




 (adsbygoogle = window.adsbygoogle || []).push({});