Questions tagged [greenfoot]

Greenfoot is an environment that makes it very easy to create 2D animations and games using Java.

Greenfoot is designed for beginners and makes it easy for people who have never programmed before to create games and animations without worrying about dealing with any complexities such as threading, double buffering or swing.

After scenarios have been created they can easily be shared by using the Greenfoot Gallery.

Links:

Main site (download Greenfoot here)

Greenfoot Gallery (users scenarios are published here)

Greenroom (only open to teachers)

128 questions
-2
votes
1 answer

I am not sure why this is showing an error

I am not sure why this is showing an error on greenfoot.It says this is an incompatible type. How to fix it , as shown here
-2
votes
1 answer

Stacks in Java, why does it use an if?

Below is the code for a Stack program. My question specifically is about the push method, where at the beginning, it checks if (pContent != null). Why does it do that? I commented the if statement out and it still worked fine, so whats the reason…
diatomym
  • 163
  • 1
  • 2
  • 11
-2
votes
1 answer

Level select in programming assignment

First post here, probably wont be my last. I have a major assignment due and we were supplied with a task and code to go with it. The assignment is basically to recreate pacman. I am stuck with it, as when all the markers are removed it is meant to…
-2
votes
3 answers

Difference between else if and if (Java)

I was wondering if there's any difference between these two codes: Code 1: if(isSleepy()){ sleep(1); } else if (isBored()){ dance(); dance(); } else { walkRight(50); walkLeft(50); if(isHungry()){ eat(); } } Code…
Dreadlockyx
  • 181
  • 1
  • 11
-3
votes
1 answer

Adding a score function

I need to add some sort of score at the top, but I'm not sure how. I've tried playing around with some of functions and moving around score functions but I'm coming up without a proper score counter. Here's the User players class: Score myInt = new…
TravJ14
  • 27
  • 8
-4
votes
2 answers

Greenfoot, using "this"

I am just starting to use greenfoot and I am looking into some examples and find that people often use "this", what does it exactly mean, I don't really understand, for example: //set the animal's age public void setAge(int age) { this.age =…
FpRoT
  • 63
  • 1
  • 2
  • 12
-7
votes
2 answers

In java, is there anyway to go from a array of objects that got returned to the number of objects in the array?

In other words I get {b,b,b} I want 3. I am trying to replicate Conway's Game of Life and I want the cell to return the number of neighboring cells. Right now all it does is find out if there are object near it and if there are it stores them in an…
-9
votes
2 answers

Getter and Setter methods

I'm doing a Java assignment in Greenfoot and I'm stuck on a question about getter and setter methods which I cannot find an answer to. I'm asked to write a getter and setter method for three attributes (name, colour, age) and then use these methods…
1 2 3
8
9