Hi all,
Me and a friend are currently working on a programme, and for the life of us we cant get it to do what it's being told to! (I mean we just have no idea

)
We both are not very strong in coding so any help in the right direction will be very much appreciated. We both don't expect and want the coding to be simply given to us as then we will never learn!
The scenario:
At the moment, we want a charecter to pick up items from the world by simply moving over it. Then to drop it into a container.
Great, we have that working, but! We only want the charecter to only pick up only one item at a time this is where we are strugelling.
Not sure what to give you guys so i will chuck it all in there!
The interface we are using is Greenfoot.
import greenfoot.*; // (World, Actor, GreenfootImage, and Greenfoot)
/**
* Write a description of class Prat here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Prat extends Actor
{
private int X;
private int Y;
private boolean carryRubish = false;
private int pocket2;
private int total;
public Prat()
{
pocket2 = 0;
total = 0;
}
/**
* Act - do whatever the Prat wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
if(foundrubish()) {
pickuprubish();
}
if(foundBin()) {
putinBin();
}
move();
}
/**
* Check whether there is a rubish in the same cell as we are.
*/
public boolean foundrubish()
{
Actor rubish = getOneObjectAtOffset(0, 0, rubish.class);
if(rubish != null) {
return true;
}
else {
return false;
}
}
/**
* Pick up rubish.
*/
public void pickuprubish()
{
Actor rubish = getOneObjectAtOffset(0, 0, rubish.class);
if(rubish != null) {
//if(pocket2 = 0) {
// eat the leaf...
getWorld().removeObject(rubish);
pocket2 = pocket2 + 1;
carryRubish = true;
}
//}
}
public boolean foundBin()
{
Actor Bin = getOneObjectAtOffset(0, 0, Bin.class);
if(Bin != null) {
return true;
}
else {
return false;
}
}
public void putinBin()
{
Actor Bin = getOneObjectAtOffset(0, 0, Bin.class);
if(Bin !=null) {
if (carryRubish = true) {
total = total + 1;
carryRubish = false;
pocket2 = pocket2 - 1;
}
}
}
public void move()
{
X = getX();
Y = getY();
if(Greenfoot.isKeyDown("up")) {
setLocation(X, Y - 1);
setImage("up.jpg");
}
if(Greenfoot.isKeyDown("left")) {
setLocation(X - 1, Y);
setImage("left.jpg");
}
if(Greenfoot.isKeyDown("right")) {
setLocation(X + 1, Y);
setImage("right.jpg");
}
if(Greenfoot.isKeyDown("down")) {
setLocation(X, Y + 1);
setImage("down.jpg");
}
}
}
Boyee