hey guys in im senior IT PCS II and im having trouble configuring all my codes here the code i need help with sry for the long txtimport greenfoot.*;
import java.util.Collection;
import java.lang.Class;
/**
* RecyclingBin should wait in corners(600,400,1) and just pick up flying by paperballs.Also add to the counter getCountPP??Do you guys think it should be a bigger map at all:? im t h inkin maybe
*
* @author (your name)
* @version (a version number or a date)
*/
public class recyclingBin extends Actor
{
private boolean touched = false;
/**
* Act - do whatever the RecyclingBin wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
move(0);
recyclingBin.Actor(recyclePaperball);
setLocation((double)x, (double)y);
double x=getX(400);
double x=getY(600);
removeObjects();
if (recyclignBin != null)
{
recycle(paperball);
Greenfoot.playSound(sound);
}
if(recyclePaperball)
{
removeObject(paperball);
++getCounterPP();
}
else if (!touched && body != null)
{
touched = false;
}
}
public void setLocation(double getX, double getY)
{
double X = Greenfoot.getX(400,400,0,0);
double Y = Greenfoot.getY(600,0,600,0);
}
public void getIntersectingObjects()
{
Actor recyclingBin = getIntersectingObjects(0, 0, paperball.class);
if(paperball != null) {
// eat the pperball...
getWorld().removeObject(paperball);
getCountPP = getCountPP + 1;
}
}
}
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.util.List;
/**
* to push the paperballs into the bins and be able to move around the map with ease of arrow keys
*
* @author (your name)
* @version (a version number or a date)
*/
public class user extends Actor
{
private double move;
/**
* goal is to only push paperballs in a new direction with the character of the game. Fromthere they can attempt to recycle more often to win.
*/
public void act()
{
//COMMENTSFORREADERS//here it tells me .class expected but idk why if i have the x and y's.
setLocation(int x, int y);
PushBallInNewDirection();
}
public void move(double distance)
{
double angle = Math.toRadians( getRotation() );
int x = getX() + (int)Math.round(Math.cos(rotation)*distance);
int y = getY() + (int)Math.round(Math.sin(rotation)*distance);
setLocation(x, y);
}
public void setLocation(int x, int y)
{
int x= (200);
int y= (250);
setLocation(x,y);
}
private void PushBallInNewDirection()
//check if user runs into paperball, if so return paperball into opposite direction
{
if(Greenfoot.mouseClicked(this))
{
PushBallInNewDirection();
}
}
static boolean isKeyDown(String key)
{
if(Greenfoot.isKeyDown("left"))
{
move(7);
}
if (Greenfoot.isKeyDown("right"))
{
move(7);
}
if (Greenfoot.isKeyDown("up"))
{
move(5);
}
if (Greenfoot.isKeyDown("down"))
{
move(5);
}
}
private void getIntersectingObjects()
{
Actor user = getIntersectingObjects(0, 0, paperball.class);
if(paperball != null) {
// swat the pperball...
getWorld().PushBallInNewDirection(paperball);
swatCounter = swatCounter + 1;
}
}
}
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.util.List;
/**
* paperballs should be placed random, they should fly with a inconsistent speed and direction and be intended to *be pushed into bins. i hope to code them correctly with gravity forces for a better grade but i'm struggling at managing that as of now...
* @author (your name)
* @version (a version number or a date)
*/
public class paperball extends Actor
{
private static final double GRAVITY = 7.8;
private double mass;
/**
* Act - do whatever the paperball wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public paperball()
{
this (20, 300, new Vector());
}
public paperball(int size, double mass, Vector movement)
{ move(37);
this.mass = mass;
if(Greenfoot.getRandomNumber(100) < 10)
{
turn(Greenfoot.getRandomNumber(90) - 45);
}
}
public void randomPaperballs(int howMany)
{
for(int i=0; i<howMany; i++) {
paperball paperball = new paperball();
int x = Greenfoot.getRandomNumber(getWidth());
int y = Greenfoot.getRandomNumber(getHeight());
addObject(paperball, x, y);
}
}
public void act(int rnum)
{
int rnum = Greenfoot.getRandomNumber(4) ;
if (rnum == 0)
{
setLocation( getX() + 1 , getY() ) ;
moveAndTurn();
}
if (rnum == 1)
{
setLocation( getX() - 1 , getY() ) ;
moveAndTurn();
}
if (rnum == 2)
{
setLocation( getX() , getY() + 1) ;
moveAndTurn();
}
if (rnum == 3)
{
setLocation( getX() , getY() - 1 ) ;
moveAndTurn();
}
applyForces();
}
private void checkCollision()
{
Actor a = getOneIntersectingObject(recyclingBin.class);
if (a != null)
{
World world = getWorld();
world.removeObject(this);
}
}
private void applyForces()
{
List<paperball> paperballs = (List<paperball>) getWorld().getObjects(paperball.class);
for (Paperball paperball : paperballs)
{
if (paperball != this)
{
applyGravity (paperball);
}
}
// ensure that we don't get too fast: If the current speed is very fast, decelerate a bit.
if (getSpeed() > 7)
{
accelerate (1.4); // acceleration with factor < 1 is actually slowing down.
}
}
private void applyGravity(paperball other)
{
double dx = other.getExactX() - this.getExactX();
double dy = other.getExactY() - this.getExactY();
Vector force = new Vector (dx, dy);
double distance = Math.sqrt (dx*dx + dy*dy);
double strength = GRAVITY * this.mass * other.mass / (distance * distance);
double acceleration = strength / this.mass;
force.setLength (acceleration);
addForce (force);
}
}
I also have counter smoothmover and vector class. only errors elsewhere are in counter and space. can post those too. Thanks greatly for any help or constructive criticism appreciated much

