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

General programming help

Why was I sent here?

You may have been directed to this page because you have asked a question which is broad and which doesn't properly explain what you need help with. In general for someone to help you they will need to ask lots of generic questions to find out exactly what you need, and why you can't do it yourself. This is a waste of time for both you and the people that are trying to help you. This page gives guidance on how to make your questions clear and complete, to avoid wasting anyone's time, and to increase the chance that someone will help you.

There are four general pieces of advice here:

  1. "I don't know where to start!"
  2. Break your problem into parts
  3. Don't say that you need help "fast"
  4. Be specific about what you are having trouble with

1. "I don't know where to start!"

People sometimes give a description of a task that they've been assigned or an idea for a game that they have, and then say: I don't know where to start! When you say this, without giving more information, it is impossible to help you, because it's not clear what kind of help you actually need. Some general guidelines are:

First, make sure you understand the basics of Java programming. You should understand how to declare and use variables and methods, and how to use 'if' statements. You should also be familiar with the methods that Greenfoot makes available. If you do not yet know these basics, you should go through the tutorials and videos before you ask any questions (you can find them in the Documentation section). If you don't understand anything from the tutorials then you can ask specific questions until you are comfortable with the basics.

Once you've got a grasp of the basics, a good place to start your task is by identifying the classes that you will need. This is usually straightforward. For a Greenfoot scenario you'll need a world subclass (even if it doesn't do anything special) and (usually) a class for each type of actor that you want to show in the world. So for example in a game where you move a baddle to bounce a ball and destroy bricks, you'd need a world class ("BrickWorld"), a "Paddle" class, a "Brick" class and a "Ball" class.

Then, break your problem into parts (see section 2). You can then start tackling the pieces one at a time. For each piece of the problem:

  • Think about whether you need variables to it. Are there any values or objects that you need to keep track of? Where would these variables go?
  • Think about what methods you might be able to use. You can check the online documentation for the Greenfoot classes to see a complete list of the methods that are available (there are a lot, but not so many that you can't read the whole list fairly quickly).
  • Think about what conditions you need to check in order to solve your problem. Usually checking a condition needs an 'if' statement. Can you think what condition you need to test? Can you see where the 'if' statement would go?

Then try writing some code, based on your thoughts. It doesn't matter if it doesn't work - the fact that you tried will make people more willing to help you. If you really feel like you don't know what to write, at least include your thoughts from the three points above in your question. Be detailed!

For example:

Example (bad): I need to make a ball move around the world and bounce off the edges, how do I do that? I don't know where to start.

Example (better): I need to make a ball move around the world and bounce off the edges. I've thought about it and it seems like maybe I need some variable to track the direction the ball is travelling in, maybe an 'int' because it is an angle? And I know I can use the 'getX' and 'getY' methods to get the location of the ball, but I don't know to check whether the location is at the edge of the world. Can someone help me figure out what condition I need to use in the 'if' statement?

Including some code with your question will make it much more likely that people will try to help you. But even if you can't include any code, showing that you have made a real effort to understand the problem will also make people more willing to spend time to help you.

2. Break your problem into parts.

If you have a problem to solve, the first step is to break it into parts. Then you can tackle the smaller parts one by one. If you don't know how to do one of the parts, you can ask about that particular part of the problem. It is usually much easier for people to give advice about a small problem than it is about a vague, general problem.

Example (bad): I need to make a ball move around the world and bounce off the edges, how do I do that?

Broken into parts:

  1. How do I make an object move?
  2. How can I detect when an object has reached an edge of the world?
  3. How do I make an object change direction?

Now you can ask about only the parts that you're having trouble with.

For example (better): I'm trying to make a ball move around the edges and bounce off the edge of the world. I'm stuck on how to detect when the ball has reached the edge of the world, can anyone help?

This example is much better, but it's still not a great question - there are other ways that it can be improved!

2. Don't say that you need help "fast"!

When people help you, it's because they choose to do some good for someone they don't know. In general, they want to help you learn so that in the future you will be a more capable programmer. So, when someone says they need help fast they are less likely to want help you at all.

  • Asking for help fast implies that you don't care about learning - you just want to get code written so that you can pass your assignment (for example). But that defeats the purpose of the assignment, which is to test your understanding.
  • You aren't paying the people who are helping you. They have no obligation to help you at all, and so asking them to help fast can seem rude.
  • Sometimes people are willing to help, but not right now. If you say you need help fast, they might ignore your question because they assume that their help will come "too late" and that you will not be grateful.
  • Saying that you have a deadline is just as bad as saying that you need help fast. The deadline is your issue - it is not something that should concern anyone who is trying to help you.

Example (bad): I need to make a platform game where the player jumps around and collects strawberries from platforms, and it goes to the next level when all the strawberries are eaten. Pls help quickly cos I need to do this for my assignment and it's due tomorrow!

Example (better): I need to make a platform game where the player jumps around and collects strawberries from platforms. I can make the player walk left and right but I'm having trouble with the jumping. I'd appreciate any help, thanks!

3. Be specific about what you are having trouble with

To help you, someone will need to know exactly what it is that you're having trouble with. So you need to be specific. Give lots of detail about what you're trying to do, and which parts you can't do (either because you don't know how to write the code, or you wrote some code but it doesn't work).

If you are getting an error message, supply the full and exact text of the error message. Just saying that "It says something about an undefined symbol", for example, is too vague. Make sure to say what line number the error occurs on (or mark it with a comment in the code). If you get an exception (a series of lines in red, in Greenfoot's terminal window), post the full stack trace from the terminal window.

Always include relevant code that you have written, even if it doesn't work or doesn't contain functionality that you're trying to implement. This is a big help to those trying to help you, because they can directly suggest how you might change your code to make it work. If you haven't written any code then you should read the first section, "I don't know where to start!", and lay out your answers to the questions listed there.

To build from the previous example:

Example (bad): I need to make a platform game where the player jumps around and collects strawberries from platforms. I can make the player walk left and right but I'm having trouble with the jumping. I'd appreciate any help, thanks!

Example (better): I need to make a platform game where the player jumps around and collects strawberries from platforms. I can make the player walk left and right but I'm having trouble with the jumping. When I try to jump (using spacebar) my player just falls through the platform that he's standing on! The code for my player class is below; the code that is supposed to handle jumping is in the "jump" and "fall" methods. I'd appreciate any help, thanks!