This site requires JavaScript, please enable it in your browser!
Greenfoot back
Lordkallad
Lordkallad wrote ...

2016/4/21

getHeight Nullpointerexception

Lordkallad Lordkallad

2016/4/21

#
Hi everyone I have a problem i can't solve by myself. First of all, i mad a class Melee, subclass of Mob. In class Mob, i have a boolean that predicts if the actor is on the ground or not, using getImage().getHeight(); etc (found that in many exemples) Everything worked well until i tried to animate the melee class. I call my images in the Melee class. Melee uses the onGround boolean that is defined in Mob. When i launch the programm it returns a Nullpointerexception, related to onGround, and on getImage().getHeight(); After a few tests, i discovered the problem came not from getImage(). So it's the getHeight method that dont find any target. I dont know why and can't find a solution Thanks for helping me And sorry for my poor english Lordkallad
danpost danpost

2016/4/21

#
You need to show the complete error trace you got on your terminal as well as the code around which the error occurred (at least the method). Indicate the line number in the class of the first line of your post.
umer umer

2016/4/22

#
Hi I am new to greenfoot please can somebody help me with this assignment? Lab Input Output 1a: Ask the user to input the price of a product and the discount percentage. The discount percentage will be input as an integer (not a decimal value) so a 20% discount will be input as 20. Create a method that will calculate the amount of discount on the product by using the price and discount percentage. Make sure to keep in mind how Integer Division works in Java so you calculate the discount properly. Output the price, discount amount, and sale price. Make sure to use the DecimalFormat class so the dollar amounts are formatted properly. The output should be centered in the world and should look exactly like this (with different numbers based on the user input of course): Price: $12.50 Discount: $2.50 Sale Price: $10.00
danpost danpost

2016/4/22

#
@umer, yours is a totally different type of issue. It has nothing in common with the discussion so far. Why would you post your issue here and not start a new discussion thread? Also, you need to be more specific as to what you are having problems with. As is, it appears you want us to do your homework for you. There is another recent discussion that discusses the use of the DecimalFormat class; so you could check that out as far as its use is concerned.
You need to login to post a reply.